initializeRedisStore attempts to create and initialize Redis store Falls back to in-memory store if Redis connection fails
()
| 76 | // initializeRedisStore attempts to create and initialize Redis store |
| 77 | // Falls back to in-memory store if Redis connection fails |
| 78 | func (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 | } |
no test coverage detected