Documentation ¶
Index ¶
- Variables
- type Addable
- type Locker
- type Manager
- type NullStore
- func (n *NullStore) Decrement(context.Context, string, int) (int, error)
- func (n *NullStore) Flush(context.Context) (bool, error)
- func (n *NullStore) Forever(context.Context, string, any) (bool, error)
- func (n *NullStore) Forget(context.Context, string) (bool, error)
- func (n *NullStore) Get(context.Context, string, any) error
- func (n *NullStore) GetPrefix() string
- func (n *NullStore) Has(context.Context, string) (bool, error)
- func (n *NullStore) Increment(context.Context, string, int) (int, error)
- func (n *NullStore) Lock(string, time.Duration) locker.Locker
- func (n *NullStore) Put(context.Context, string, any, time.Duration) (bool, error)
- type Repository
- type Snapshot
- type SnapshotWithErr
- type Store
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFound = errors.New("cache: the key is not found")
Functions ¶
This section is empty.
Types ¶
type Addable ¶
type Addable interface { // Add stores the value into the cache with an expiration time if the key does not exist. // If the key exists, the return value will be false, and the return error will be nil. // If the key does not exist, the return value will be true, and the return error will be nil. // otherwise, the return error will be the store error. Add(ctx context.Context, key string, value any, ttl time.Duration) (bool, error) }
type Manager ¶ added in v2.8.0
type Manager struct { Repository // contains filtered or unexported fields }
func NewManager ¶ added in v2.8.0
func NewManager(repository Repository) *Manager
func (*Manager) Driver ¶ added in v2.8.0
func (m *Manager) Driver(names ...string) Repository
func (*Manager) Register ¶ added in v2.8.0
func (m *Manager) Register(name string, repository Repository)
type NullStore ¶ added in v2.16.0
type NullStore struct{}
type Repository ¶
type Repository interface { Store Addable Missing(ctx context.Context, key string) (bool, error) Delete(ctx context.Context, key string) (bool, error) Set(ctx context.Context, key string, value any, ttl time.Duration) (bool, error) }
func NewRepository ¶
func NewRepository(store Store) Repository
type Snapshot ¶ added in v2.27.0
type Snapshot[K comparable, V any] struct { // contains filtered or unexported fields }
type SnapshotWithErr ¶ added in v2.27.0
type SnapshotWithErr[K comparable, V any] Snapshot[K, valueWithError[V]]
func (*SnapshotWithErr[K, V]) Lookup ¶ added in v2.27.0
func (c *SnapshotWithErr[K, V]) Lookup(key K, fn func() (V, error)) (V, error)
type Store ¶
type Store interface { Locker // Has returns true if the key exists in the cache. // If the key does not exist, the return value will be false, and the return error will be nil. // If the key exists, the return value will be true, and the return error will be nil. // otherwise, the return error will be the store error. Has(ctx context.Context, key string) (bool, error) // Get retrieves the value from the cache. // If the key does not exist, the dest will be unchanged, and the return error will be ErrNotFound. // If the key exists, the value will be unmarshaled to dest, and the return error will be nil. // otherwise, the return error will be the store error. Get(ctx context.Context, key string, dest any) error // Put stores the value into the cache with an expiration time. // If put success, the return value will be true, and the return error will be nil. // otherwise, the return value will be false, and the return error will be the store error. Put(ctx context.Context, key string, value any, ttl time.Duration) (bool, error) // Increment increments the value in the cache. // If the key does not exist, the before default value is 0. Increment(ctx context.Context, key string, value int) (int, error) // Decrement decrements the value in the cache. // If the key does not exist, the before default value is 0. Decrement(ctx context.Context, key string, value int) (int, error) Forever(ctx context.Context, key string, value any) (bool, error) Forget(ctx context.Context, key string) (bool, error) Flush(ctx context.Context) (bool, error) GetPrefix() string }
Click to show internal directories.
Click to hide internal directories.