Documentation
¶
Index ¶
- Variables
- type Cache
- func (cd *Cache) Delete(ctx context.Context, key string) error
- func (cd *Cache) DeleteFromLocalCache(key string)
- func (cd *Cache) Exists(ctx context.Context, key string) bool
- func (cd *Cache) Get(ctx context.Context, key string, value interface{}) error
- func (cd *Cache) GetS(ctx context.Context, keys []string, skipLocalCache bool) ([][]byte, error)
- func (cd *Cache) GetSkippingLocalCache(ctx context.Context, key string, value interface{}) error
- func (cd *Cache) Marshal(value interface{}) ([]byte, error)
- func (cd *Cache) Once(item *Item) error
- func (cd *Cache) Set(item *Item) error
- func (cd *Cache) SetS(ctx context.Context, items []*Item) error
- func (cd *Cache) Unmarshal(b []byte, value interface{}) error
- type Item
- type MarshalFunc
- type Options
- type UnmarshalFunc
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrCacheMiss = errors.New("cache: key is missing")
)
Functions ¶
This section is empty.
Types ¶
type Cache ¶
func (*Cache) DeleteFromLocalCache ¶
func (*Cache) GetSkippingLocalCache ¶
Get gets the value for the given key skipping local cache.
func (*Cache) Once ¶
Once gets the item.Value for the given item.Key from the cache or executes, caches, and returns the results of the given item.Func, making sure that only one execution is in-flight for a given item.Key at a time. If a duplicate comes in, the duplicate caller waits for the original to complete and receives the same results.
type Item ¶
type Item struct { Ctx context.Context Key string Value interface{} // TTL is the cache expiration time. // Default TTL is 1 hour. TTL time.Duration // Do returns value to be cached. Do func(*Item) (interface{}, error) // SetXX only sets the key if it already exists. SetXX bool // SetNX only sets the key if it does not already exist. SetNX bool // SkipLocalCache skips local cache as if it is not set. SkipLocalCache bool }
type MarshalFunc ¶
type Options ¶
type Options struct { Redis c3.Rediser LocalCache c3.LocalCache StatsEnabled bool Marshal MarshalFunc Unmarshal UnmarshalFunc }
type UnmarshalFunc ¶
Click to show internal directories.
Click to hide internal directories.