cache

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package cache provides in-memory caching functionalities for data access objects (DAOs), including cache management, record storage, retrieval, and synchronization with the underlying database.

Index

Constants

This section is empty.

Variables

View Source
var Cache = cache{}

Functions

func Activate

func Activate(data any) error

func AddEntries

func AddEntries(data []*any) error

func AddEntry

func AddEntry(data any) error

func Clear

func Clear(table entities.Table) error

func ClearAllCaches

func ClearAllCaches() error

func ClearCacheForType

func ClearCacheForType(data any) error

func Count

func Count(data any) (int64, error)

func DeInitialise

func DeInitialise(data any) error

func Disable

func Disable(data any) error

func FindByIndex

func FindByIndex[T any](data T, index entities.Field, value any) ([]*T, error)

func FindByKey

func FindByKey[T any](data T, key any) (*T, error)

func Get

func Get[T any](data T, key any) (*T, error)

func GetAll

func GetAll[T any](data T) ([]*T, error)

func GetAllWhere

func GetAllWhere[T any](data T, index entities.Field, value any) ([]*T, error)

func GetExpiry

func GetExpiry(data any) (time.Duration, error)

func GetWhere

func GetWhere[T any](data T, index entities.Field, value any) (*T, error)

func Hydrate

func Hydrate(table entities.Table) error

func HydrateAll

func HydrateAll() error

func HydrateForType

func HydrateForType(data any) error

func Initialise

func Initialise()

func IsDeInitialised

func IsDeInitialised(data any) bool

func IsDisabled

func IsDisabled(data any) bool

func IsEnabled

func IsEnabled(data any) bool

IsEnabled checks if the cache for the given data type is enabled.

Parameters:

  • data: The data type to check the cache status for.

Returns:

  • bool: True if the cache is enabled for the given data type; otherwise, false.

func IsInitialised

func IsInitialised(data any) bool

func PurgeExpiredEntries

func PurgeExpiredEntries()

Remove any cached entries that have expired

func RegisterExpiry

func RegisterExpiry(data any, duration time.Duration) error

func RegisterHydrator

func RegisterHydrator(data any, hydrator func() ([]any, error))

func RegisterIndex

func RegisterIndex(data any, key entities.Field) error

func RegisterKey

func RegisterKey(data any, key entities.Field) error

func RegisterSynchroniser

func RegisterSynchroniser(data any, synchroniser func(any) error)

func RemoveByKey

func RemoveByKey(data any, key any) error

func RemoveEntry

func RemoveEntry(data any) error

func RemoveIndex

func RemoveIndex(data any, key entities.Field) error

func Spew

func Spew()

func SpewFor

func SpewFor(tableName entities.Table)

SpewFor outputs the same cache report detail as Spew(), but scoped to a single table.

The table name should match the cache's internal table key (typically the struct type name as derived by the cache package).

func SpewForType

func SpewForType(data any)

SpewForType outputs the same cache report detail as Spew(), but scoped to the table associated with the provided record type.

Example:

cache.SpewForType(templateStoreV2.TemplateStore{})

func Stats

func Stats() (created time.Time, updated time.Time, noTables int64, noCacheEntries int64)

func Synchronise

func Synchronise(table entities.Table) error

func SynchroniseAll

func SynchroniseAll() error

func SynchroniseEntry

func SynchroniseEntry(data any) error

func SynchroniseForType

func SynchroniseForType(data any) error

func Update

func Update(data any) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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