db.v3: upper.io/db.v3/internal/cache Index | Files | Directories

package cache

import "upper.io/db.v3/internal/cache"


Package Files

cache.go interface.go

func Hash Uses

func Hash(v interface{}) string

Hash returns a hash of the given struct.

type Cache Uses

type Cache struct {
    // contains filtered or unexported fields

Cache holds a map of volatile key -> values.

func NewCache Uses

func NewCache() *Cache

NewCache initializes a new caching space with default settings.

func NewCacheWithCapacity Uses

func NewCacheWithCapacity(capacity int) (*Cache, error)

NewCacheWithCapacity initializes a new caching space with the given capacity.

func (*Cache) Clear Uses

func (c *Cache) Clear()

Clear generates a new memory space, leaving the old memory unreferenced, so it can be claimed by the garbage collector.

func (*Cache) Read Uses

func (c *Cache) Read(h Hashable) (string, bool)

Read attempts to retrieve a cached value as a string, if the value does not exists returns an empty string and false.

func (*Cache) ReadRaw Uses

func (c *Cache) ReadRaw(h Hashable) (interface{}, bool)

ReadRaw attempts to retrieve a cached value as an interface{}, if the value does not exists returns nil and false.

func (*Cache) Write Uses

func (c *Cache) Write(h Hashable, value interface{})

Write stores a value in memory. If the value already exists its overwritten.

type HasOnPurge Uses

type HasOnPurge interface {

HasOnPurge type is (optionally) implemented by cache objects to clean after themselves.

type Hashable Uses

type Hashable interface {
    Hash() string

Hashable types must implement a method that returns a key. This key will be associated with a cached value.

func String Uses

func String(s string) Hashable

String returns a Hashable that produces a hash equal to the given string.



Package cache imports 6 packages (graph) and is imported by 7 packages. Updated 2019-01-22. Refresh now. Tools for package owners.