utils

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWebSocketCacheNotReady error = errors.New("webSocket cache is not ready")
	ErrWebSocketCacheStale    error = errors.New("webSocket cache is stale")
)

Functions

This section is empty.

Types

type CacheResponse

type CacheResponse[Key comparable, T any] struct {
	LastUpdated *time.Time `json:"lastUpdated"`
	Items       map[Key]T  `json:"items"`
}

type MemoryCacheInstance

type MemoryCacheInstance[Key comparable, T any] struct {
	// contains filtered or unexported fields
}

func NewMemoryCacheInstance

func NewMemoryCacheInstance[Key comparable, T any](maxAllowedAge *time.Duration) *MemoryCacheInstance[Key, T]

func (*MemoryCacheInstance[Key, T]) Delete

func (cache *MemoryCacheInstance[Key, T]) Delete(key Key)

func (*MemoryCacheInstance[Key, T]) Get

func (cache *MemoryCacheInstance[Key, T]) Get(key Key) (T, bool)

func (*MemoryCacheInstance[Key, T]) GetAll

func (cache *MemoryCacheInstance[Key, T]) GetAll() (CacheResponse[Key, T], error)

func (*MemoryCacheInstance[Key, T]) GetCacheAge

func (cache *MemoryCacheInstance[Key, T]) GetCacheAge() *time.Duration

func (*MemoryCacheInstance[Key, T]) GetLastUpdated

func (cache *MemoryCacheInstance[Key, T]) GetLastUpdated() *time.Time

func (*MemoryCacheInstance[Key, T]) Replace

func (cache *MemoryCacheInstance[Key, T]) Replace(freshData map[Key]T)

func (*MemoryCacheInstance[Key, T]) Reset

func (cache *MemoryCacheInstance[Key, T]) Reset()

func (*MemoryCacheInstance[Key, T]) Update

func (cache *MemoryCacheInstance[Key, T]) Update(key Key, item T)

Jump to

Keyboard shortcuts

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