memorycache

package
v0.0.0-...-71692c9 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2017 License: Apache-2.0 Imports: 3 Imported by: 17

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
}

Cache is a synchronised map of items that auto-expire once stale

func NewCache

func NewCache(duration time.Duration) *Cache

NewCache is a helper to create instance of the Cache struct

func (*Cache) Count

func (cache *Cache) Count() int

Count returns the number of items in the cache (helpful for tracking memory leaks)

func (*Cache) Get

func (cache *Cache) Get(key string) (data *bucket, found bool)

Get is a thread-safe way to lookup items Every lookup, also touches the item, hence extending it's life

func (*Cache) Set

func (cache *Cache) Set(key string, data *bucket)

Set is a thread-safe way to add new items to the map

type Item

type Item struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Item represents a record in the cache map

type Storage

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

Storage is a non thread-safe in-memory leaky bucket factory.

func New

func New() *Storage

New initializes the in-memory bucket store.

func (*Storage) Create

func (s *Storage) Create(name string, capacity uint, rate time.Duration) (leakybucket.Bucket, error)

Create a bucket.

Jump to

Keyboard shortcuts

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