Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MemoryCache ¶
type MemoryCache[K comparable, T any] struct { // contains filtered or unexported fields }
MemoryCache store data in memory, will be used to cache user group permission rule.
func NewMemoryCache ¶
func NewMemoryCache[K comparable, V any]() *MemoryCache[K, V]
NewMemoryCache 不对缓存的对象进行序列化,直接用 sync.Map 保存在内存里。
过期的缓存不会从内存中自动回收,不能用来缓存值空间非常大的数据如条目或用户, 用于缓存用户组权限这样的值空间比较小的数据。
type RedisCache ¶
type RedisCache interface { Get(ctx context.Context, key string, value any) (bool, error) Set(ctx context.Context, key string, value any, ttl time.Duration) error Del(ctx context.Context, keys ...string) error }
RedisCache
var s model.Subject c.Get(ctx, key, &s) c.Set(ctx, key, s, time.Minute)
func NewNoop ¶
func NewNoop() RedisCache
func NewRedisCache ¶
func NewRedisCache(cli *redis.Client) RedisCache
NewRedisCache create a redis backed cache.
Click to show internal directories.
Click to hide internal directories.