cache

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2020 License: Apache-2.0 Imports: 3 Imported by: 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
}

Cache is a barebones cache implementation.

func NewCache

func NewCache(o ...Option) Cache

NewCache returns a new instance of Cache.

func (*Cache) Evict

func (c *Cache) Evict()

Evict frees memory from the cache by removing invalid keys. It is a noop.

func (*Cache) Get

func (c *Cache) Get(svcKey, key string) (*Entry, error)

Get gets an entry on a service `svcKey` by a give `key`.

func (*Cache) Invalidate

func (c *Cache) Invalidate(svcKey, key string) error

Invalidate invalidates a cache Entry by key.

func (*Cache) Length

func (c *Cache) Length(k string) int

Length returns the amount of entries per service key.

func (*Cache) Set

func (c *Cache) Set(svcKey, key string, val interface{}) error

Set sets a key / value. It lets a service add entries on a request basis.

type Entry

type Entry struct {
	V     interface{}
	Valid bool
}

Entry represents an entry on the cache. You can type assert on V.

type Option

type Option func(*Options)

Option mutates option

func Size

func Size(s int) Option

Size configures the size of the cache in items.

func TTL

func TTL(ttl time.Duration) Option

TTL rebuilds the cache after the configured duration.

type Options

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

Options are all the possible options.

Jump to

Keyboard shortcuts

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