cache

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMemoryCache

func NewMemoryCache(prefix string) cache.Store

Types

type Application

type Application struct {
	Store  cache.Store
	Prefix string
}

func (*Application) Init

func (app *Application) Init() cache.Store

type Memory

type Memory struct {
	Prefix string
	Client contractStorage.Storage
}

func (*Memory) Add

func (r *Memory) Add(key string, value any, seconds time.Duration) bool

Add Store an item in the cache if the key does not exist.

func (*Memory) Flush

func (r *Memory) Flush() bool

Flush Remove all items from the cache.

func (*Memory) Forever

func (r *Memory) Forever(key string, value any) bool

Forever Store an item in the cache indefinitely.

func (*Memory) Forget

func (r *Memory) Forget(key string) bool

Forget Remove an item from the cache.

func (*Memory) Get

func (r *Memory) Get(key string, def any) any

Get Retrieve an item from the cache by key.

func (*Memory) GetBool

func (r *Memory) GetBool(key string, def bool) bool

func (*Memory) GetInt

func (r *Memory) GetInt(key string, def int) int

func (*Memory) GetString

func (r *Memory) GetString(key string, def string) string

func (*Memory) Has

func (r *Memory) Has(key string) bool

Has Check an item exists in the cache.

func (*Memory) Pull

func (r *Memory) Pull(key string, def any) any

Pull Retrieve an item from the cache and delete it.

func (*Memory) Put

func (r *Memory) Put(key string, value any, seconds time.Duration) error

Put Store an item in the cache for a given number of seconds.

func (*Memory) Remember

func (r *Memory) Remember(key string, ttl time.Duration, callback func() any) (any, error)

Remember Get an item from the cache, or execute the given Closure and store the result.

func (*Memory) RememberForever

func (r *Memory) RememberForever(key string, callback func() any) (any, error)

RememberForever Get an item from the cache, or execute the given Closure and store the result forever.

func (*Memory) WithContext

func (r *Memory) WithContext(ctx context.Context) cache.Store

WithContext Retrieve an item from the cache by key.

type ServiceProvider

type ServiceProvider struct {
	Store  cache.Store
	Prefix string
}

func (*ServiceProvider) Boot

func (database *ServiceProvider) Boot()

func (*ServiceProvider) Register

func (database *ServiceProvider) Register()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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