Help us shape the future of Go! Take the 2026 Go Developer Survey

cache2

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2017 License: Apache-2.0 Imports: 4 Imported by: 1

README

cache2

A cache implementation in Go

This is used in uniqush-push

Because some installations of uniqush-push predate versioned dependencies, this was created as a repo separate from uniqush/cache, because of the inconvenience caused by interface incompatibilities.

License: Apache-2.0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func New

func New(capacity int, maxNrDirty int, flushPeriod time.Duration, flusher Flusher) *Cache

capacity: nr elements in the cache. capacity < 0 means always in memory; capacity = 0 means no cache.

maxNrDirty: < 0 means no flush.

flushPeriod: flushPeriod > 1 second means periodically flush; flushPeriod = 0 second means no periodically flush; undefined in range (0, 1).

func (*Cache) Delete

func (c *Cache) Delete(key string) interface{}

func (*Cache) Flush

func (c *Cache) Flush()

func (*Cache) Get

func (c *Cache) Get(key string) interface{}

func (*Cache) Len

func (c *Cache) Len() int

func (*Cache) Set

func (c *Cache) Set(key string, value interface{})

type CacheInterface

type CacheInterface interface {
	Len() int
	Set(key string, value interface{})
	Get(key string) interface{}
	Delete(key string) interface{}
	Flush()
	// contains filtered or unexported methods
}

type Flusher

type Flusher interface {
	Add(key string, value interface{})
	Remove(key string)
}

type SimpleCache

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

func NewSimple

func NewSimple(capacity int) *SimpleCache

func (*SimpleCache) Delete

func (c *SimpleCache) Delete(key string) interface{}

func (*SimpleCache) Flush

func (c *SimpleCache) Flush()

func (*SimpleCache) Get

func (c *SimpleCache) Get(key string) interface{}

func (*SimpleCache) Len

func (c *SimpleCache) Len() int

func (*SimpleCache) Set

func (c *SimpleCache) Set(key string, value interface{})

Jump to

Keyboard shortcuts

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