cache2go

package
v0.9.1-rc3 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2014 License: GPL-3.0, BSD-3-Clause Imports: 4 Imported by: 0

README

cache2go

Golang simple object caching library with expiration capabilities.

See the test file for wroking examples.

API docs here.

Continous integration: Build Status

Documentation

Overview

Simple caching library with expiration capabilities

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cache

func Cache(key string, value interface{})

The function to be used to cache a key/value pair when expiration is not needed

func CountEntries

func CountEntries(prefix string) (result int)

func Flush

func Flush()

Delete all keys from cache

func GetCached

func GetCached(key string) (v interface{}, err error)

The function to extract a value for a key that never expire

func GetKeyAge

func GetKeyAge(key string) (time.Duration, error)

func GetXCached

func GetXCached(key string) (ece expiringCacheEntry, err error)

Get an entry from the expiration cache and mark it for keeping alive

func GetXKeyAge

func GetXKeyAge(key string) (time.Duration, error)

func RemKey

func RemKey(key string)

func RemPrefixKey

func RemPrefixKey(prefix string)

func XCountEntries

func XCountEntries(prefix string) (result int)

func XFlush

func XFlush()

Delete all keys from expiraton cache

func XRemKey

func XRemKey(key string)

func XRemPrefixKey

func XRemPrefixKey(prefix string)

Types

type XEntry

type XEntry struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Structure that must be embeded in the objectst that must be cached with expiration. If the expiration is not needed this can be ignored

func (*XEntry) KeepAlive

func (xe *XEntry) KeepAlive()

Mark entry to be kept another expirationDuration period

func (*XEntry) XCache

func (xe *XEntry) XCache(key string, expire time.Duration, value expiringCacheEntry)

The main function to cache with expiration

Jump to

Keyboard shortcuts

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