mem

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCache = New(time.Minute)

DefaultCache is default cache for surge

Functions

func Delete

func Delete(dst Data, key string)

Delete is a surge, it delete a specified data in DefaultCache

func Remember

func Remember(dst Data, key string) error

Remember is a surge, it provides a quite simple way to use cache

Types

type Cache

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

Cache is the definition of cache, be careful of the memory usage

func New

func New(rotateInterval time.Duration) *Cache

New create a cache entity with a custom expiration time

func (*Cache) Delete

func (c *Cache) Delete(dst Data, key string)

Delete immediately specified the cached content to expire

func (*Cache) Remember

func (c *Cache) Remember(dst Data, key string) error

Remember automatically save and retrieve data from a cache entity

func (*Cache) Rotate

func (c *Cache) Rotate(reset bool)

Rotate force refresh cached data

type Data

type Data interface {
	Fulfill(key string) (err error)
}

Data define the type which can speed up by mem cache

Jump to

Keyboard shortcuts

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