MCPcopy
hub / github.com/appleboy/gin-jwt / initializeRedisStore

Method initializeRedisStore

auth_jwt_redis.go:78–96  ·  view source on GitHub ↗

initializeRedisStore attempts to create and initialize Redis store Falls back to in-memory store if Redis connection fails

()

Source from the content-addressed store, hash-verified

76// initializeRedisStore attempts to create and initialize Redis store
77// Falls back to in-memory store if Redis connection fails
78func (mw *GinJWTMiddleware) initializeRedisStore() {
79 if mw.UseRedisStore {
80 // Try to create Redis store
81 redisConfig := mw.RedisConfig
82 if redisConfig == nil {
83 redisConfig = store.DefaultRedisConfig()
84 }
85
86 redisStore, err := store.NewRedisRefreshTokenStore(redisConfig)
87 if err != nil {
88 // Fallback to in-memory store
89 log.Printf("Failed to connect to Redis: %v, falling back to in-memory store", err)
90 mw.RefreshTokenStore = mw.inMemoryStore
91 } else {
92 log.Println("Successfully connected to Redis store with client-side cache enabled")
93 mw.RefreshTokenStore = redisStore
94 }
95 }
96}

Callers 1

MiddlewareInitMethod · 0.95

Calls 2

DefaultRedisConfigFunction · 0.92

Tested by

no test coverage detected