Documentation
¶
Index ¶
- func CachedFunc[T any](f T, encache Encache, expiry time.Duration) T
- func Expire(encache Encache, key string, expiry time.Duration) error
- type CacheKeyImpl
- type CacheKeyType
- type CacheType
- type Encache
- type LockType
- type MapCacheImpl
- func (cacheImpl *MapCacheImpl) Deserialize(serializedResult string, fType reflect.Type) ([]reflect.Value, error)
- func (cacheImpl *MapCacheImpl) Expire(key string, expiry time.Duration) error
- func (cacheImpl *MapCacheImpl) Get(key string, _ reflect.Type) ([]reflect.Value, bool, error)
- func (cacheImpl *MapCacheImpl) PeriodicExpire(runOnDuration time.Duration)
- func (cacheImpl *MapCacheImpl) Serialize(res []reflect.Value) (string, error)
- func (cacheImpl *MapCacheImpl) Set(key string, value []reflect.Value, expiry time.Duration) error
- type MuLockImpl
- type NoLockImpl
- type RedisCacheImpl
- func (cacheImpl *RedisCacheImpl) Deserialize(serializedResult string, fType reflect.Type) ([]reflect.Value, error)
- func (cacheImpl *RedisCacheImpl) Expire(key string, expiry time.Duration) error
- func (cacheImpl *RedisCacheImpl) Get(key string, fType reflect.Type) ([]reflect.Value, bool, error)
- func (cacheImpl *RedisCacheImpl) PeriodicExpire(_ time.Duration)
- func (cacheImpl *RedisCacheImpl) Serialize(res []reflect.Value) (string, error)
- func (cacheImpl *RedisCacheImpl) Set(key string, value []reflect.Value, expiry time.Duration) error
- type RedisLockImpl
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CachedFunc ¶
closure = returned anonymous inner function + outer context(variables defined outside of inner function) get the instance of function f with caching logic
Types ¶
type CacheKeyImpl ¶
type CacheKeyImpl struct{}
func NewDefaultCacheKeyImpl ¶
func NewDefaultCacheKeyImpl() *CacheKeyImpl
type CacheType ¶
type CacheType interface { Get(string, reflect.Type) ([]reflect.Value, bool, error) Set(string, []reflect.Value, time.Duration) error Serialize([]reflect.Value) (string, error) Deserialize(string, reflect.Type) ([]reflect.Value, error) PeriodicExpire(time.Duration) Expire(string, time.Duration) error }
type Encache ¶
type Encache struct { LockImpl LockType CacheImpl CacheType CacheKeyImpl CacheKeyType SetCacheOnErr bool }
func NewEncache ¶
type MapCacheImpl ¶
type MapCacheImpl struct {
// contains filtered or unexported fields
}
func (*MapCacheImpl) Deserialize ¶
func (cacheImpl *MapCacheImpl) Deserialize(serializedResult string, fType reflect.Type) ([]reflect.Value, error)
just to satisfy the interface
func (*MapCacheImpl) Expire ¶
func (cacheImpl *MapCacheImpl) Expire(key string, expiry time.Duration) error
expire after a certain duration
func (*MapCacheImpl) PeriodicExpire ¶
func (cacheImpl *MapCacheImpl) PeriodicExpire(runOnDuration time.Duration)
start a goroutine to periodically check and remove expired cache entries
type MuLockImpl ¶
type MuLockImpl struct {
// contains filtered or unexported fields
}
func NewMuLockImpl ¶
func NewMuLockImpl() *MuLockImpl
type RedisCacheImpl ¶
type RedisCacheImpl struct {
// contains filtered or unexported fields
}
func NewRedisCacheImpl ¶
func NewRedisCacheImpl(client redis.UniversalClient) *RedisCacheImpl
func (*RedisCacheImpl) Deserialize ¶
func (*RedisCacheImpl) Expire ¶
func (cacheImpl *RedisCacheImpl) Expire(key string, expiry time.Duration) error
func (*RedisCacheImpl) PeriodicExpire ¶
func (cacheImpl *RedisCacheImpl) PeriodicExpire(_ time.Duration)
just to satisfy the interface as expirations happens automatically
type RedisLockImpl ¶
type RedisLockImpl struct {
// contains filtered or unexported fields
}
func NewRedisLockImpl ¶
func NewRedisLockImpl(client redis.UniversalClient, lockTimeout time.Duration) *RedisLockImpl
Click to show internal directories.
Click to hide internal directories.