mem

package module
v0.0.0-...-8673ab5 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2019 License: MIT Imports: 6 Imported by: 0

README

mem

mem is a simple and safe mem cache tool

Aims

  • type safe
  • race safe
  • flood prevention
  • high performance
  • simple (KISS)
  • user friendly

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 CacheType, key interface{})

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

func Remember

func Remember(dst CacheType, key interface{}) 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 CacheType, key interface{})

Delete immediately specified the cached content to expire

func (*Cache) Remember

func (c *Cache) Remember(dst CacheType, key interface{}) error

Remember automatically save and retrieve data from a cache entity

type CacheType

type CacheType interface {
	GetOne(key interface{}) (interface{}, error)
}

CacheType 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