Documentation
¶
Overview ¶
https://github.com/kristoff-it/redis-memolock https://redis.com/blog/caches-promises-locks/
Index ¶
- Variables
- func InvalidAll(ctx context.Context, group string, client RedisClient) error
- func InvalidAllCluster(ctx context.Context, group string, client RedisClient) error
- func Marshal(v interface{}) ([]byte, error)
- func SchemaToStore(pkg string, path string, prefix string, stores []*StoreSchema) error
- func Unmarshal(data []byte, v interface{}) error
- type CachePipeline
- type CacheStore
- type ExternalFetchFunc
- type FetchFunc
- type LockRenewFunc
- type Logger
- type NOPLogger
- type RedisClient
- type RedisMemoLock
- func (r *RedisMemoLock) AddGroup(ctx context.Context, group string, key string) error
- func (r *RedisMemoLock) Close()
- func (r *RedisMemoLock) DeleteCache(ctx context.Context, key string) error
- func (r *RedisMemoLock) GetCached(ctx context.Context, key string) ([]byte, error)
- func (r *RedisMemoLock) GetCachedP(ctx context.Context, pipe redis.Pipeliner, key string) *redis.StringCmd
- func (r *RedisMemoLock) Lock(ctx context.Context, key string) (bool, error)
- func (r *RedisMemoLock) SetCache(ctx context.Context, key string, value []byte, ttl time.Duration) error
- func (r *RedisMemoLock) SingleGroup() *singleflight.Group
- func (r *RedisMemoLock) Wait(ctx context.Context, key string) ([]byte, error)
- func (r *RedisMemoLock) WaitSingle(ctx context.Context, key string) ([]byte, error)
- type RenewableFetchFunc
- type StoreSchema
Constants ¶
This section is empty.
Variables ¶
var ErrClosing = errors.New("operation canceled by close()")
ErrClosing happens when calling Close(), all pending requests will be failed with this error
var ErrLockRenew = errors.New("unable to renew the lock")
ErrLockRenew happens when trying to renew a lock that expired already
var ErrTimeOut = errors.New("operation timed out")
ErrTimeOut happens when the given timeout expires
Functions ¶
func InvalidAll ¶
func InvalidAll(ctx context.Context, group string, client RedisClient) error
func InvalidAllCluster ¶
func InvalidAllCluster(ctx context.Context, group string, client RedisClient) error
func SchemaToStore ¶
func SchemaToStore(pkg string, path string, prefix string, stores []*StoreSchema) error
Types ¶
type CachePipeline ¶
func NewPipeline ¶
func NewPipeline(client RedisClient) *CachePipeline
type CacheStore ¶
type CacheStore interface { }
type ExternalFetchFunc ¶
type ExternalFetchFunc = func() error
ExternalFetchFunc has the same purpose as FetchFunc but works on the assumption that the value will be set in Redis and notificed on Pub/Sub by an external program
type FetchFunc ¶
FetchFunc is the function that the caller should provide to compute the value if not present in Redis already. time.Duration defines for how long the value should be cached in Redis.
type LockRenewFunc ¶
LockRenewFunc is the function that RenewableFetchFunc will get as input and that must be called to extend a locks' life
type RedisClient ¶
type RedisMemoLock ¶
type RedisMemoLock struct {
// contains filtered or unexported fields
}
RedisMemoLock implements the "promise" mechanism
func NewRedisMemoLock ¶
func NewRedisMemoLock(ctx context.Context, prefix string, client RedisClient, resourceTag string, lockTimeout time.Duration) (*RedisMemoLock, error)
NewRedisMemoLock Creates a new RedisMemoLock instance
func (*RedisMemoLock) Close ¶
func (r *RedisMemoLock) Close()
Close stops listening to Pub/Sub and resolves all pending subscriptions with ErrClosing.
func (*RedisMemoLock) DeleteCache ¶
func (r *RedisMemoLock) DeleteCache(ctx context.Context, key string) error
func (*RedisMemoLock) GetCachedP ¶
func (r *RedisMemoLock) GetCachedP(ctx context.Context, pipe redis.Pipeliner, key string) *redis.StringCmd
func (*RedisMemoLock) SingleGroup ¶ added in v0.1.2
func (r *RedisMemoLock) SingleGroup() *singleflight.Group
func (*RedisMemoLock) WaitSingle ¶ added in v0.1.2
type RenewableFetchFunc ¶
type RenewableFetchFunc = func(LockRenewFunc) (string, time.Duration, error)
RenewableFetchFunc has the same purpose as FetchFunc but, when called, it is offered a function that allows to extend the lock
Directories
¶
Path | Synopsis |
---|---|
cacheme
Code generated by cacheme, DO NOT EDIT.
|
Code generated by cacheme, DO NOT EDIT. |
cacheme/store
Code generated by cacheme, DO NOT EDIT.
|
Code generated by cacheme, DO NOT EDIT. |