sqlcore

package module
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package sqlcore provides the shared SQL-backed cache store implementation. For dialect-specific registrations, prefer driver/sqlitecache, driver/postgrescache, or driver/mysqlcache.

Example:

// Import a database/sql driver (or use a dialect wrapper package) before calling sqlcore.New.
store, err := sqlcore.New(sqlcore.Config{
	DriverName: "pgx",
	DSN:        "postgres://user:pass@localhost:5432/app?sslmode=disable",
	Table:      "cache_entries",
	Prefix:     "app",
})
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(cfg Config) (cachecore.Store, error)

New builds a SQL-backed cachecore.Store (postgres, mysql, sqlite).

Defaults: - Table: "cache_entries" when empty - DefaultTTL: 5*time.Minute when zero - Prefix: "app" when empty - DriverName: required - DSN: required

Example: advanced shared SQL core config

store, err := sqlcore.New(sqlcore.Config{
	BaseConfig: cachecore.BaseConfig{
		DefaultTTL: 5 * time.Minute,
		Prefix:     "app",
	},
	DriverName: "sqlite",
	DSN:        "file::memory:?cache=shared",
	Table:      "cache_entries",
})
if err != nil {
	panic(err)
}
fmt.Println(store.Driver()) // sql

Types

type Config

type Config struct {
	cachecore.BaseConfig
	DriverName string
	DSN        string
	Table      string
}

Config configures a SQL-backed cache store.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL