Documentation
¶
Index ¶
Constants ¶
View Source
const PlaceholderPrefix = "valkeyid:"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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() valkey.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 valkey.Client used by Locker ClientBuilder func(option valkey.ClientOption) (valkey.Client, error) ClientOption valkey.ClientOption ClientTTL time.Duration // TTL for the client marker, refreshed every 1/2 TTL. Defaults to 10s. The marker allows other client to know if this client is still alive. UseLuaLock bool }
type TypedCacheAsideClient ¶
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 ¶
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.
Click to show internal directories.
Click to hide internal directories.