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 ¶
- Variables
- func Activate(data any) error
- func AddEntries(data []any) error
- func AddEntry(data any) error
- func Clear(table entities.Table) error
- func ClearAllCaches() error
- func ClearCacheForType(data any) error
- func Count(data any) (int64, error)
- func DeInitialise(data any) error
- func Disable(data any) error
- func FindByIndex[T any](data T, index entities.Field, value any) ([]T, error)
- func FindByKey[T any](data T, key any) (T, error)
- func Get[T any](data T, key any) (T, error)
- func GetAll[T any](data T) ([]T, error)
- func GetAllWhere[T any](data T, index entities.Field, value any) ([]T, error)
- func GetExpiry(data any) (time.Duration, error)
- func GetWhere[T any](data T, index entities.Field, value any) (T, error)
- func Hydrate(table entities.Table) error
- func HydrateAll() error
- func HydrateForType(data any) error
- func Initialise()
- func IsDeInitialised(data any) bool
- func IsDisabled(data any) bool
- func IsEnabled(data any) bool
- func IsInitialised(data any) bool
- func PurgeExpiredEntries()
- func RegisterExpiry(data any, duration time.Duration) error
- func RegisterHydrator(data any, hydrator func() ([]any, error))
- func RegisterIndex(data any, key entities.Field) error
- func RegisterKey(data any, key entities.Field) error
- func RegisterSynchroniser(data any, synchroniser func(any) error)
- func RemoveByKey(data any, key any) error
- func RemoveEntry(data any) error
- func RemoveIndex(data any, key entities.Field) error
- func Spew()
- func SpewFor(tableName entities.Table)
- func SpewForType(data any)
- func Stats() (created time.Time, updated time.Time, noTables int64, noCacheEntries int64)
- func Synchronise(table entities.Table) error
- func SynchroniseAll() error
- func SynchroniseEntry(data any) error
- func SynchroniseForType(data any) error
- func Update(data any) error
Constants ¶
This section is empty.
Variables ¶
View Source
var Cache = cache{}
Functions ¶
func AddEntries ¶
func ClearAllCaches ¶
func ClearAllCaches() error
func ClearCacheForType ¶
func DeInitialise ¶
func HydrateAll ¶
func HydrateAll() error
func HydrateForType ¶
func Initialise ¶
func Initialise()
func IsDeInitialised ¶
func IsDisabled ¶
func IsEnabled ¶
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 RegisterHydrator ¶
func RegisterSynchroniser ¶
func RemoveByKey ¶
func RemoveEntry ¶
func SpewFor ¶
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 Synchronise ¶
func SynchroniseAll ¶
func SynchroniseAll() error
func SynchroniseEntry ¶
func SynchroniseForType ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.