Documentation
¶
Overview ¶
Package sqlkv implements kv.Cache on a single table of the SQL database you already run for theauth storage. It works on Postgres, MySQL and SQLite.
Build the full set of shared stores with kv.FromCache(store). Create the table once with EnsureSchema (idempotent) or run Schema(dialect) in your own migration tool.
Index ¶
- Constants
- func Schema(d Dialect, table string) string
- type Dialect
- type Option
- type Store
- func (s *Store) Delete(ctx context.Context, key string) error
- func (s *Store) EnsureSchema(ctx context.Context) error
- func (s *Store) Get(ctx context.Context, key string) ([]byte, bool, error)
- func (s *Store) Incr(ctx context.Context, key string, ttl time.Duration) (int64, error)
- func (s *Store) Prune(ctx context.Context) (int64, error)
- func (s *Store) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
- func (s *Store) SetNX(ctx context.Context, key string, value []byte, ttl time.Duration) (bool, error)
Constants ¶
const DefaultTable = "theauth_kv"
DefaultTable is the table name used when none is given.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(*Store)
Option tunes New.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements kv.Cache over database/sql.
func (*Store) EnsureSchema ¶
EnsureSchema creates the table and its expiry index when missing.
func (*Store) Prune ¶
Prune deletes expired rows and returns how many it removed. Writes call it opportunistically; call it from a timer if the table sees little traffic.