hashcache

package
v0.0.0-...-ba1c585 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2017 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package hashcache implements a simple cache intended to be indexed by hash values. The keys are of type []byte. Values are arbitrary interface{} values. Entries may expire if not used for a duration specified by the client.

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
}

A Cache allows the user to store arbitrary values, keyed by the contents of byte vectors. Entries may be added, deleted, and looked up. They may expire if not used.

func New

func New(expiry time.Duration) *Cache

New() returns a pointer to a new, empty Cache. Entries may expire if not used for "expiry".

func (*Cache) Add

func (c *Cache) Add(key []byte, data interface{})

Add() associates data with key[] in *c. Any data previously associated with key[] are forgotten. The implementation may discard the association at some future time (set by NewCache()) to limit the size of the cache. data may not be modified after this call; it is shared with *c.

func (*Cache) Delete

func (c *Cache) Delete(key []byte)

Delete() removes any association of data with key[] in *c.

func (*Cache) Lookup

func (c *Cache) Lookup(key []byte) (data interface{}, isPresent bool)

Lookup() returns the data associated with key[] in *c, and whether there is such a value. The client may not modify the returned data; it is shared with *c.

Jump to

Keyboard shortcuts

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