cache

package
v0.0.0-...-6781889 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(key string)

func Exists

func Exists(key string) bool

func Get

func Get(key string, v any) bool

func GetBool

func GetBool(key string) (bool, bool)

func GetOrAdd

func GetOrAdd[T interface{}](key string, v *T, creator func(k string) (T, error)) error

func Set

func Set(key string, value any)

func SetBool

func SetBool(key string, v bool)

Types

type Cache

type Cache interface {
	GetOrAdd(key string, creator func(k string) ([]byte, error)) []byte
	Get(key string) ([]byte, bool)
	Set(key string, value []byte)
	Delete(key string)
	Exits(key string) bool
}

func NewMemoryCache

func NewMemoryCache(options *CacheOptions) Cache

type CacheOptions

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

type MemoryCache

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

func (*MemoryCache) Delete

func (c *MemoryCache) Delete(key string)

func (*MemoryCache) Exits

func (c *MemoryCache) Exits(key string) bool

func (*MemoryCache) Get

func (c *MemoryCache) Get(key string) ([]byte, bool)

func (*MemoryCache) GetOrAdd

func (c *MemoryCache) GetOrAdd(key string, creator func(k string) ([]byte, error)) []byte

func (*MemoryCache) Set

func (c *MemoryCache) Set(key string, value []byte)

Jump to

Keyboard shortcuts

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