cache

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicCache

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

func (*BasicCache[K, V]) Add

func (c *BasicCache[K, V]) Add(key K, value V, expiration time.Duration) bool

Add add new time to cache

  • expiration: 0 for disable expire cache

func (*BasicCache[K, V]) Delete

func (c *BasicCache[K, V]) Delete(key K) bool

func (*BasicCache[K, V]) Exists

func (c *BasicCache[K, V]) Exists(key K) bool

func (*BasicCache[K, V]) Get

func (c *BasicCache[K, V]) Get(key K) (V, bool)

func (*BasicCache[K, V]) Keys

func (c *BasicCache[K, V]) Keys() []K

func (*BasicCache[K, V]) Update

func (c *BasicCache[K, V]) Update(key K, newValue V, expiration time.Duration) bool

type Cache

type Cache[K any, V any] interface {
	// Add store your item to cache
	Add(key K, value V, expiration time.Duration) bool
	// Get load your item from cache
	Get(key K) (V, bool)
	// Update updates the Value of an existing entry in the cache.
	Update(key K, newValue V, expiration time.Duration) bool
	// Exists check your key exists in cache
	Exists(key K) bool
	// Keys return list of keys in cache
	Keys() []K
	// Delete delete specific item from cache base on key
	Delete(key K) bool
}

func NewBasic

func NewBasic[K any, V any](cleanUpCheckDuration time.Duration, options ...Option) Cache[K, V]

type EmptyServerOption

type EmptyServerOption struct{}

type Option

type Option interface {
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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