Documentation ¶
Overview ¶
Example ¶
package main import ( "context" "fmt" "log" "time" "github.com/dsh2dsh/expx-cache/redis" ) func main() { redisCache, _ := redis.MustNew() ctx := context.Background() err := redisCache.Set(redis.MakeSetIter3(ctx, []string{"key1", "key2"}, [][]byte{[]byte("value1"), []byte("value2")}, []time.Duration{time.Minute, 2 * time.Minute})) if err != nil { log.Fatal(err) } iterBytes, err := redisCache.Get(redis.MakeGetIter3( ctx, []string{"key1", "key2"})) if err != nil { log.Fatal(err) } for b, ok := iterBytes(); ok; b, ok = iterBytes() { fmt.Println(string(b)) } err = redisCache.Del(ctx, []string{"key1", "key2"}) if err != nil { log.Fatal(err) } }
Output:
Index ¶
- func MakeGetIter3(ctx context.Context, keys []string) (context.Context, int, func(itemIdx int) string)
- func MakeSetIter3(ctx context.Context, keys []string, blobs [][]byte, times []time.Duration) (context.Context, int, ...)
- type Cmdable
- type RedisCache
- func (self *RedisCache) Del(ctx context.Context, keys []string) error
- func (self *RedisCache) Expire(ctx context.Context, key string, ttl time.Duration) (bool, error)
- func (self *RedisCache) Get(ctx context.Context, maxItems int, keyIter func(itemIdx int) (key string)) (func() ([]byte, bool), error)
- func (self *RedisCache) Listen(ctx context.Context, key string, ready ...func() error) (string, error)
- func (self *RedisCache) LockGet(ctx context.Context, keySet, value string, ttl time.Duration, keyGet string) (ok bool, b []byte, err error)
- func (self *RedisCache) Set(ctx context.Context, maxItems int, ...) error
- func (self *RedisCache) Unlock(ctx context.Context, key, value string) (bool, error)
- func (self *RedisCache) WithBatchSize(size int) *RedisCache
- func (self *RedisCache) WithGetRefreshTTL(ttl time.Duration) *RedisCache
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeGetIter3 ¶
Types ¶
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
func New ¶
func New(rdb Cmdable) *RedisCache
func (*RedisCache) WithBatchSize ¶
func (self *RedisCache) WithBatchSize(size int) *RedisCache
func (*RedisCache) WithGetRefreshTTL ¶
func (self *RedisCache) WithGetRefreshTTL(ttl time.Duration) *RedisCache
Click to show internal directories.
Click to hide internal directories.