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 ¶
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 ¶
Click to show internal directories.
Click to hide internal directories.