Skip to content
Discussion options

You must be logged in to vote

You are not missing a built-in Redis switch in the docs. In the current code, Limen has a generic CacheAdapter interface and defaults to NewMemoryCacheStore() when Config.CacheStore is nil.

That shared cache is used by cache-backed sessions, the rate limiter, and JWT blacklist storage. Redis support is expected to be plugged in by providing your own Config.CacheStore implementation.

The shape is roughly:

type RedisCacheStore struct {
    client *redis.Client
}

func (r *RedisCacheStore) Get(ctx context.Context, key string) ([]byte, error) {
    b, err := r.client.Get(ctx, key).Bytes()
    if errors.Is(err, redis.Nil) {
        return nil, limen.ErrRecordNotFound
    }
    return b, err
}

f…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ineo7
Comment options

Answer selected by thecodearcher
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants