cache

package
v0.0.0-...-bea3eb9 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

DigiStratum GoLib - Cache

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCacheItem

func NewCacheItem(key string, value interface{}, expires chrono.TimeStampIfc) *cacheItem

------------------------------------------------------------------------------------------------- Factory Functions -------------------------------------------------------------------------------------------------

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache() *Cache

Make a new one of these!

func (*Cache) Close

func (r *Cache) Close() error

func (*Cache) Configure

func (r *Cache) Configure(config cfg.ConfigIfc) error

func (*Cache) Count

func (r *Cache) Count() int

Return the count of entries currently being held in this cache

func (*Cache) Drop

func (r *Cache) Drop(key string) (bool, error)

Drop an item from the cache with the supplied key return true if we drop it, else false

func (*Cache) DropAll

func (r *Cache) DropAll(keys *[]string) (int, error)

Check whether we have configuration elements for all the key names return count of items actually dropped

func (*Cache) Flush

func (r *Cache) Flush()

Flush all the items out of the cache

func (*Cache) Get

func (r *Cache) Get(key string) interface{}

Get a single cache element by key name

func (*Cache) GetExpires

func (r *Cache) GetExpires(key string) chrono.TimeStampIfc

Get the expiration timestamp for a given Cache item; returns nil if not set

func (*Cache) GetKeys

func (r *Cache) GetKeys() []string

func (*Cache) Has

func (r *Cache) Has(key string) bool

Check whether we have a configuration element by key name

func (*Cache) HasAll

func (r *Cache) HasAll(keys *[]string) bool

Check whether we have configuration elements for all the key names

func (*Cache) IsEmpty

func (r *Cache) IsEmpty() bool

Check whether this Cache is empty (has no properties)

func (*Cache) IsRunning

func (r *Cache) IsRunning() bool

func (*Cache) Run

func (r *Cache) Run()

func (*Cache) Set

func (r *Cache) Set(key string, value interface{}) bool

Set a single cache element key to the specified value

func (*Cache) SetExpires

func (r *Cache) SetExpires(key string, expires chrono.TimeStampIfc) bool

Set the expiration timestamp for a given Cache item; returns true if set, else false

func (*Cache) SetTimeSource

func (r *Cache) SetTimeSource(timeSource chrono.TimeSourceIfc)

func (*Cache) Size

func (r *Cache) Size() int64

Get the number of properties in this Cache

func (*Cache) Stop

func (r *Cache) Stop()

type CacheIfc

type CacheIfc interface {
	Configure(config cfg.ConfigIfc) error // cfg.ConfigurableIfc
	SetTimeSource(timeSource chrono.TimeSourceIfc)
	IsEmpty() bool
	Size() int64
	Count() int
	Set(key string, value interface{}) bool
	SetExpires(key string, expires chrono.TimeStampIfc) bool
	GetExpires(key string) chrono.TimeStampIfc
	Get(key string) interface{}
	GetKeys() []string
	Has(key string) bool
	HasAll(keys *[]string) bool
	Drop(key string) (bool, error)
	DropAll(keys *[]string) (int, error)
	Flush()
	Close() error
}

type CacheItemIfc

type CacheItemIfc interface {
	IsExpired() bool
	SetExpires(expires chrono.TimeStampIfc)
	GetExpires() chrono.TimeStampIfc
	GetValue() interface{}
	GetKey() string
	Size() int64
}

Jump to

Keyboard shortcuts

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