synccache

package
v0.0.0-...-7a9c835 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: MIT Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry[V any] struct {
	// contains filtered or unexported fields
}

func NewEntry

func NewEntry[V any](value V, expire time.Duration) *Entry[V]

func (*Entry[V]) AddExpiration

func (e *Entry[V]) AddExpiration(d time.Duration)

func (*Entry[V]) IsExpired

func (e *Entry[V]) IsExpired() bool

func (*Entry[V]) SetExpiration

func (e *Entry[V]) SetExpiration(t time.Time)

func (*Entry[V]) Value

func (e *Entry[V]) Value() V

type SyncCache

type SyncCache[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewSyncCache

func NewSyncCache[K comparable, V any](trimTime time.Duration, conf ...SyncCacheConfig[K, V]) *SyncCache[K, V]

func (*SyncCache[K, V]) Clear

func (sc *SyncCache[K, V]) Clear()

func (*SyncCache[K, V]) CompareAndDelete

func (sc *SyncCache[K, V]) CompareAndDelete(key K, oldEntry *Entry[V]) (success bool)

func (*SyncCache[K, V]) CompareValueAndDelete

func (sc *SyncCache[K, V]) CompareValueAndDelete(key K, oldValue V) (success bool)

func (*SyncCache[K, V]) Delete

func (sc *SyncCache[K, V]) Delete(key K)

func (*SyncCache[K, V]) Load

func (sc *SyncCache[K, V]) Load(key K) (value *Entry[V], loaded bool)

func (*SyncCache[K, V]) LoadAndDelete

func (sc *SyncCache[K, V]) LoadAndDelete(key K) (value *Entry[V], loaded bool)

func (*SyncCache[K, V]) LoadOrStore

func (sc *SyncCache[K, V]) LoadOrStore(key K, value V, expire time.Duration) (actual *Entry[V], loaded bool)

func (*SyncCache[K, V]) Range

func (sc *SyncCache[K, V]) Range(f func(key K, value *Entry[V]) bool)

func (*SyncCache[K, V]) Store

func (sc *SyncCache[K, V]) Store(key K, value V, expire time.Duration)

type SyncCacheConfig

type SyncCacheConfig[K comparable, V any] func(sc *SyncCache[K, V])

func WithDeletedCallback

func WithDeletedCallback[K comparable, V any](callback func(v V)) SyncCacheConfig[K, V]

Jump to

Keyboard shortcuts

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