cache

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get[T any](key string, getFunc func() (T, error)) (T, error)

Get returns the key value from cache with callback when no key exists in cache

func Initialize

func Initialize(c Cache)

func Remove

func Remove(key string)

Remove key from cache

Types

type Cache

type Cache interface {
	// Put puts value into cache with key and expire time.
	Put(key string, val any, timeout int64) error
	// Get gets cached value by given key.
	Get(key string) any
	// IsExist checks if key exists
	IsExist(key string) bool
	Delete(key string) error
}

Cache represents a caching interface

func GetCache

func GetCache() Cache

GetCache returns the currently configured cache

Jump to

Keyboard shortcuts

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