Documentation
¶
Overview ¶
Example ¶
package main
import (
"context"
"fmt"
"log"
"slices"
"time"
"github.com/dsh2dsh/expx-cache/model"
cacheRedis "github.com/dsh2dsh/expx-cache-redis"
)
func main() {
redisCache, _ := cacheRedis.MustNew()
ctx := context.Background()
err := redisCache.Set(ctx, 2, slices.Values([]model.RedisItem{
model.NewRedisItem("key1", []byte("value1"), time.Minute),
model.NewRedisItem("key2", []byte("value2"), 2*time.Minute),
}))
if err != nil {
log.Fatal(err)
}
iterBytes := redisCache.Get(ctx, 2, slices.Values([]string{"key1", "key2"}))
for b, err := range iterBytes {
if err != nil {
log.Fatal(err)
}
fmt.Println(string(b))
}
err = redisCache.Del(ctx, []string{"key1", "key2"})
if err != nil {
log.Fatal(err)
}
}
Index ¶
- type Cache
- func (self *Cache) Del(ctx context.Context, keys []string) error
- func (self *Cache) Expire(ctx context.Context, key string, ttl time.Duration) (bool, error)
- func (self *Cache) Get(ctx context.Context, maxItems int, keys iter.Seq[string]) iter.Seq2[[]byte, error]
- func (self *Cache) Listen(ctx context.Context, key string, ready ...func() error) (string, error)
- func (self *Cache) LockGet(ctx context.Context, keySet, value string, ttl time.Duration, keyGet string) (ok bool, b []byte, err error)
- func (self *Cache) Set(ctx context.Context, maxItems int, items iter.Seq[model.RedisItem]) error
- func (self *Cache) Unlock(ctx context.Context, key, value string) (bool, error)
- func (self *Cache) WithBatchSize(size int) *Cache
- func (self *Cache) WithGetRefreshTTL(ttl time.Duration) *Cache
- type Cmdable
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.
