Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCache ¶
func NewCache[K comparable, V any]() v2.Cache[K, V]
NewCache returns a new cache with the given types
func NewFilesCache ¶
func NewFilesCache[K comparable, V any](dir string) v2.Cache[K, V]
NewFilesCache returns cache instance for local file system storage
func NewRedisCache ¶
func NewRedisCache[K comparable, V any](config RedisCacheConfig) v2.Cache[K, V]
NewRedisCache returns a new redis cache interface with redis instance configured
Types ¶
type Cache ¶
type Cache[K comparable, V any] struct { // contains filtered or unexported fields }
Cache is implemented by third-party packages which provide from github.com/Code-Hex/go-generics-cache
func (Cache[K, V]) SetWithExp ¶
type FilesCache ¶
type FilesCache[K comparable, V any] struct { }
func (*FilesCache[K, V]) Delete ¶
func (f *FilesCache[K, V]) Delete(key K)
func (*FilesCache[K, V]) Get ¶
func (f *FilesCache[K, V]) Get(key K) (value V, ok bool)
func (*FilesCache[K, V]) Set ¶
func (f *FilesCache[K, V]) Set(key K, val V)
func (*FilesCache[K, V]) SetWithExp ¶
func (f *FilesCache[K, V]) SetWithExp(key K, val V, exp time.Duration)
type RedisCache ¶
type RedisCache[K comparable, V any] struct { }
RedisCache is a redis cache wrapper which implemented the cache interface
func (*RedisCache[K, V]) Delete ¶
func (r *RedisCache[K, V]) Delete(key K)
func (*RedisCache[K, V]) Get ¶
func (r *RedisCache[K, V]) Get(key K) (value V, ok bool)
func (*RedisCache[K, V]) Set ¶
func (r *RedisCache[K, V]) Set(key K, val V)
func (*RedisCache[K, V]) SetWithExp ¶
func (r *RedisCache[K, V]) SetWithExp(key K, val V, exp time.Duration)
Click to show internal directories.
Click to hide internal directories.