Documentation
¶
Index ¶
Constants ¶
const PlaceholderPrefix = "rueidisid:"
Variables ¶
This section is empty.
Functions ¶
func OverrideCacheTTL ¶ added in v1.0.69
OverrideCacheTTL sets a custom TTL for the cache entry being populated in the current context. It can be called in the callback function passed to CacheAsideClient.Get() to customize the TTL based on the data being cached.
Types ¶
type CacheAsideClient ¶
type CacheAsideClient interface {
Get(ctx context.Context, ttl time.Duration, key string, fn func(ctx context.Context, key string) (val string, err error)) (val string, err error)
Del(ctx context.Context, key string) error
Client() rueidis.Client
Close()
}
func NewClient ¶
func NewClient(option ClientOption) (cc CacheAsideClient, err error)
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
type ClientOption ¶
type ClientOption struct {
// ClientBuilder can be used to modify rueidis.Client used by Locker
ClientBuilder func(option rueidis.ClientOption) (rueidis.Client, error)
ClientOption rueidis.ClientOption
ClientTTL time.Duration // TTL for the client marker, refreshed every 1/2 TTL. Defaults to 10s. The marker allows other clients to know if this client is still alive.
UseLuaLock bool
}
type TypedCacheAsideClient ¶ added in v1.0.56
type TypedCacheAsideClient[T any] interface { Get(ctx context.Context, ttl time.Duration, key string, fn func(ctx context.Context, key string) (val *T, err error)) (val *T, err error) Del(ctx context.Context, key string) error Client() CacheAsideClient }
TypedCacheAsideClient is an interface that provides a typed cache-aside client. It allows you to cache and retrieve values of a specific type T.
func NewTypedCacheAsideClient ¶ added in v1.0.56
func NewTypedCacheAsideClient[T any]( client CacheAsideClient, serializer func(*T) (string, error), deserializer func(string) (*T, error), ) TypedCacheAsideClient[T]
NewTypedCacheAsideClient creates a new TypedCacheAsideClient instance that provides a typed cache-aside client. The client, serializer, and deserializer functions are used to interact with the underlying cache. The serializer function is used to convert the provided value of type T to a string, and the deserializer function is used to convert the cached string value back to the original type T.