ttlcache

package module
v0.0.0-...-02fc6f5 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2017 License: MIT Imports: 9 Imported by: 0

README

Time-to-live Cache

The Time-to-live Cache Service provides fast caching that features persistence to a BoltDB data store. This allows the cache to persist for longer durations or with large datasets without requiring significant memory on the server. The intention is to provide a caching mechanism that can be used in a variety of circumstances and reduces the impact of frequent, intensive queries on the database server or other backend server.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByIndexEntryExpiry

type ByIndexEntryExpiry []IndexEntry

func (ByIndexEntryExpiry) Len

func (s ByIndexEntryExpiry) Len() int

func (ByIndexEntryExpiry) Less

func (s ByIndexEntryExpiry) Less(i, j int) bool

func (ByIndexEntryExpiry) Swap

func (s ByIndexEntryExpiry) Swap(i, j int)

type CacheEntry

type CacheEntry struct {
	Key       []byte
	Value     interface{}
	CreatedAt time.Time
	ExpiresAt time.Time
}

type Group

type Group struct {
	sync.Mutex
	Key []byte
	// contains filtered or unexported fields
}

func (*Group) Count

func (g *Group) Count() int

func (*Group) Delete

func (g *Group) Delete(key []byte) error

func (*Group) Get

func (g *Group) Get(key []byte) (*CacheEntry, error)

func (*Group) Put

func (g *Group) Put(key []byte, value interface{}, ttl time.Duration) error

type IndexEntry

type IndexEntry struct {
	Key       []byte
	ExpiresAt time.Time
}

type TTLCache

type TTLCache struct {
	Groups map[string]*Group
	// contains filtered or unexported fields
}

func OpenCache

func OpenCache(storagePath string, reapInterval time.Duration) (*TTLCache, error)

func (*TTLCache) Close

func (t *TTLCache) Close()

func (*TTLCache) CreateGroupIfNotExists

func (t *TTLCache) CreateGroupIfNotExists(key string) (*Group, error)

CreateGroupIfNotExists gets a group by key. If the grouiop does not exist, it will be created.

func (*TTLCache) DeleteGroup

func (t *TTLCache) DeleteGroup(key string) error

Jump to

Keyboard shortcuts

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