Documentation
¶
Index ¶
- Variables
- type Config
- type SQLiteStore
- func (s *SQLiteStore) Clear(ctx context.Context) error
- func (s *SQLiteStore) Close() error
- func (s *SQLiteStore) Delete(ctx context.Context, key string) error
- func (s *SQLiteStore) Get(ctx context.Context, key string) ([]byte, error)
- func (s *SQLiteStore) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInvalidPath is returned when Path is empty. ErrInvalidPath = errors.New("sqlite: Path must not be empty") // ErrInvalidMaxOpenConns is returned when MaxOpenConns is < 0. ErrInvalidMaxOpenConns = errors.New("sqlite: MaxOpenConns must be >= 0") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Path is the path to the SQLite database file (REQUIRED, must not be empty).
// Use ":memory:" for in-memory database.
Path string
// MaxOpenConns is the maximum number of open connections to the database (OPTIONAL).
// Default: 1 (recommended for SQLite to avoid lock contention)
// Set to 0 for unlimited connections (not recommended for SQLite).
MaxOpenConns int
// CleanupInterval is the interval for cleaning up expired entries (OPTIONAL).
// Default: 1 minute
// Set to negative value to disable automatic cleanup.
CleanupInterval time.Duration
// WALMode enables Write-Ahead Logging mode for better concurrency (OPTIONAL).
// Default: true
// Set to false to use default journal mode (not recommended).
WALMode *bool
}
Config holds configuration for SQLiteStore.
type SQLiteStore ¶
type SQLiteStore struct {
// contains filtered or unexported fields
}
SQLiteStore is a SQLite-backed cache store. Thread-safe for concurrent use with WAL mode enabled.
Reference: .references/gookit-cache/boltdb/boltdb.go (embedded database operations)
func New ¶
func New(cfg Config) (*SQLiteStore, error)
New creates a new SQLiteStore with the given configuration.
func (*SQLiteStore) Clear ¶
func (s *SQLiteStore) Clear(ctx context.Context) error
Clear removes all entries from SQLite.
func (*SQLiteStore) Close ¶
func (s *SQLiteStore) Close() error
Close releases resources associated with the SQLite database. Idempotent - safe to call multiple times.
func (*SQLiteStore) Delete ¶
func (s *SQLiteStore) Delete(ctx context.Context, key string) error
Delete removes a value from SQLite. Idempotent - deleting a non-existent key returns nil.
Click to show internal directories.
Click to hide internal directories.