Documentation ¶
Index ¶
- type Cache
- type Option
- type RedisCache
- func (r *RedisCache) Del(ctx context.Context, key string) bool
- func (r *RedisCache) Get(ctx context.Context, key string) (string, bool)
- func (r *RedisCache) Has(ctx context.Context, key string) bool
- func (r *RedisCache) Set(ctx context.Context, key string, value interface{}, ttl time.Duration)
- func (r *RedisCache) TTL(ctx context.Context, key string) time.Duration
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { Get(ctx context.Context, key string) (string, bool) Set(ctx context.Context, key string, value interface{}, ttl time.Duration) Has(ctx context.Context, key string) bool Del(ctx context.Context, key string) bool TTL(ctx context.Context, key string) time.Duration }
Cache interface
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
RedisCache is a Redis-based cache.
func NewRedisCache ¶
func NewRedisCache(client *redis.Client, opt *Option) *RedisCache
NewRedisCache creates a new RedisCache instance.
func (*RedisCache) Del ¶
func (r *RedisCache) Del(ctx context.Context, key string) bool
Del deletes the given key, panic when an error occurs.
func (*RedisCache) Get ¶
Get returns the value for the given key in cache, panic when an error occurs.
func (*RedisCache) Has ¶
func (r *RedisCache) Has(ctx context.Context, key string) bool
Has check if the cache key exists, panic when an error occurs.
Click to show internal directories.
Click to hide internal directories.