Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct { Exec redis.Cmdable // contains filtered or unexported fields }
func (*DB) CacheGet ¶ added in v0.0.15
CacheGet gets a cached value Example:
var wanted Object if err := mycache.Get(ctx, key, &wanted); err == nil { fmt.Println(wanted) }
func (*DB) CacheOnce ¶
CacheOnceItem makes a cache Once gets the item.Object 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. Example:
CacheOnceItem(&cache.Item{ Key: "mykey", Value: obj, // destination Do: func(*cache.Item) (interface{}, error) { return &Object{ Str: "mystring", Num: 42, }, nil }, })
func (*DB) CacheSet ¶ added in v0.0.15
CacheSet sets a cache Example:
ctx := context.Background() key := "mykey" obj := &Object{ Str: "mystring", Num: 42, } if err := mycache.Set(&cache.Item{ Ctx: ctx, Key: key, Value: obj, TTL: time.Hour, }); err != nil { panic(err) }
func (*DB) CacheStats ¶ added in v0.0.15
Click to show internal directories.
Click to hide internal directories.