Documentation
¶
Index ¶
- Constants
- func ClearJSON(ctx context.Context, opt ...types.SessionCacheOption) error
- func DeleteJSON(ctx context.Context, key string, opt ...types.SessionCacheOption) error
- func GetAllJSON[T any](ctx context.Context, opt ...types.SessionCacheOption) (map[string]T, error)
- func GetJSON[T any](ctx context.Context, key string, opt ...types.SessionCacheOption) (T, bool, error)
- func GetManyJSON[T any](ctx context.Context, keys []string, opt ...types.SessionCacheOption) (map[string]T, error)
- func GetSession(ctx context.Context) (types.SessionCache, error)
- func GetSyncIDFromContext(ctx context.Context) string
- func NewMemorySessionCache(ctx context.Context, opt ...types.SessionCacheConstructorOption) (types.SessionCache, error)
- func NewMemorySessionCacheWithTTL(ctx context.Context, ttl time.Duration, ...) (types.SessionCache, error)
- func SetJSON[T any](ctx context.Context, key string, item T, opt ...types.SessionCacheOption) error
- func SetManyJSON[T any](ctx context.Context, items map[string]T, opt ...types.SessionCacheOption) error
- func WithPrefix(prefix string) types.SessionCacheOption
- func WithSyncID(syncID string) types.SessionCacheOption
- type MemorySessionCache
- func (m *MemorySessionCache) Clear(ctx context.Context, opt ...types.SessionCacheOption) error
- func (m *MemorySessionCache) Close(ctx context.Context) error
- func (m *MemorySessionCache) Delete(ctx context.Context, key string, opt ...types.SessionCacheOption) error
- func (m *MemorySessionCache) Get(ctx context.Context, key string, opt ...types.SessionCacheOption) ([]byte, bool, error)
- func (m *MemorySessionCache) GetAll(ctx context.Context, opt ...types.SessionCacheOption) (map[string][]byte, error)
- func (m *MemorySessionCache) GetMany(ctx context.Context, keys []string, opt ...types.SessionCacheOption) (map[string][]byte, error)
- func (m *MemorySessionCache) Set(ctx context.Context, key string, value []byte, opt ...types.SessionCacheOption) error
- func (m *MemorySessionCache) SetMany(ctx context.Context, values map[string][]byte, opt ...types.SessionCacheOption) error
Constants ¶
const KeyPrefixDelimiter = "::"
KeyPrefixDelimiter is the delimiter used to separate prefixes from keys in the session cache.
Variables ¶
This section is empty.
Functions ¶
func DeleteJSON ¶
func GetAllJSON ¶
func GetManyJSON ¶
func GetSession ¶
func GetSession(ctx context.Context) (types.SessionCache, error)
GetSession retrieves the session cache instance from the context. Returns an error if no session cache is found in the context.
func GetSyncIDFromContext ¶
GetSyncIDFromContext retrieves the sync ID from the context, returning empty string if not found.
func NewMemorySessionCache ¶
func NewMemorySessionCache(ctx context.Context, opt ...types.SessionCacheConstructorOption) (types.SessionCache, error)
NewMemorySessionCache creates a new in-memory session cache with default TTL of 1 hour.
func NewMemorySessionCacheWithTTL ¶
func NewMemorySessionCacheWithTTL(ctx context.Context, ttl time.Duration, opt ...types.SessionCacheConstructorOption) (types.SessionCache, error)
NewMemorySessionCacheWithTTL creates a new in-memory session cache with custom TTL.
func SetManyJSON ¶
func WithPrefix ¶
func WithPrefix(prefix string) types.SessionCacheOption
func WithSyncID ¶
func WithSyncID(syncID string) types.SessionCacheOption
Types ¶
type MemorySessionCache ¶
type MemorySessionCache struct {
// contains filtered or unexported fields
}
MemorySessionCache implements SessionCache interface using an in-memory store with TTL.
func (*MemorySessionCache) Clear ¶
func (m *MemorySessionCache) Clear(ctx context.Context, opt ...types.SessionCacheOption) error
Clear removes all values from the cache.
func (*MemorySessionCache) Close ¶
func (m *MemorySessionCache) Close(ctx context.Context) error
Close performs any necessary cleanup when the cache is no longer needed.
func (*MemorySessionCache) Delete ¶
func (m *MemorySessionCache) Delete(ctx context.Context, key string, opt ...types.SessionCacheOption) error
Delete removes a value from the cache by key.
func (*MemorySessionCache) Get ¶
func (m *MemorySessionCache) Get(ctx context.Context, key string, opt ...types.SessionCacheOption) ([]byte, bool, error)
Get retrieves a value from the cache by key.
func (*MemorySessionCache) GetAll ¶
func (m *MemorySessionCache) GetAll(ctx context.Context, opt ...types.SessionCacheOption) (map[string][]byte, error)
GetAll returns all key-value pairs.
func (*MemorySessionCache) GetMany ¶
func (m *MemorySessionCache) GetMany(ctx context.Context, keys []string, opt ...types.SessionCacheOption) (map[string][]byte, error)
GetMany retrieves multiple values from the cache by keys.
func (*MemorySessionCache) Set ¶
func (m *MemorySessionCache) Set(ctx context.Context, key string, value []byte, opt ...types.SessionCacheOption) error
Set stores a value in the cache with the given key.
func (*MemorySessionCache) SetMany ¶
func (m *MemorySessionCache) SetMany(ctx context.Context, values map[string][]byte, opt ...types.SessionCacheOption) error
SetMany stores multiple values in the cache.