gocache

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 8, 2021 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoCache

type GoCache struct {
	// contains filtered or unexported fields
}
Example
c := New()
key := "name"

// set
c.Set(key, "cache value", 2*time.Second)
fmt.Println(c.Has(key))

// get
val := c.Get(key)
fmt.Println(val)

time.Sleep(2 * time.Second)

// get expired
val2 := c.Get(key)
fmt.Println(val2)

// del
c.Del(key)
fmt.Println(c.Has(key))
Output:

true
cache value
<nil>
false

func New

func New() *GoCache

func NewGoCache

func NewGoCache(defaultExpiration, cleanupInterval time.Duration) *GoCache

func (*GoCache) Clear

func (g *GoCache) Clear() error

func (*GoCache) Close

func (g *GoCache) Close() error

func (GoCache) Del

func (g GoCache) Del(key string) error

func (*GoCache) DelMulti

func (g *GoCache) DelMulti(keys []string) error

func (*GoCache) Get

func (g *GoCache) Get(key string) interface{}

func (*GoCache) GetMulti

func (g *GoCache) GetMulti(keys []string) map[string]interface{}

func (*GoCache) Has

func (g *GoCache) Has(key string) bool

func (*GoCache) Set

func (g *GoCache) Set(key string, val interface{}, ttl time.Duration) (err error)

func (GoCache) SetMulti

func (g GoCache) SetMulti(values map[string]interface{}, ttl time.Duration) (err error)

Jump to

Keyboard shortcuts

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