cache

package
v0.0.0-...-93edf92 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2018 License: BSD-3-Clause Imports: 6 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Value   interface{}
	Expiry  time.Time
	Rolling bool
}

Entry stores a cache line given a value and expiry time

func Expires

func Expires(expiry time.Time, value interface{}) Entry

Expires creates a cache entry that expires at the given time

func ExpiresRolling

func ExpiresRolling(expiry time.Time, value interface{}) Entry

ExpiresRolling creates a cache entry that expires at the given time, though expiry will roll forward when accessed

func Forever

func Forever(value interface{}) Entry

Forever creates a cache entry that shall never expire

func Value

func Value(value interface{}) Entry

Value creates a plain cache entry given a value

func (*Entry) IsExpired

func (e *Entry) IsExpired() bool

IsExpired returns true if entry is expired

func (*Entry) IsForever

func (e *Entry) IsForever() bool

IsForever returns true if entry is cached indefinitely

type Store

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

Store Party cache entries

func NewStore

func NewStore(p *redis.Pool) Store

NewStore instantiates a cache store given a Redis pool

func (*Store) Delete

func (s *Store) Delete(key string) error

Delete a cache entry

func (*Store) DeleteKeys

func (s *Store) DeleteKeys(keys []string) error

DeleteKeys deletes all given keys

func (*Store) Exists

func (s *Store) Exists(key string) (bool, error)

Exists checks for existence of a cache entry key

func (*Store) Get

func (s *Store) Get(key string) (*Entry, error)

Get a cache entry

func (*Store) GetOrDefer

func (s *Store) GetOrDefer(key string, deferFn func() (*Entry, error)) (*Entry, error)

GetOrDefer a cache entry, deferring to supplier func if entry doesn't exist or is expired. If key exists and is expired, entry is deleted

func (*Store) Set

func (s *Store) Set(key string, e Entry) error

Set a cache entry

Jump to

Keyboard shortcuts

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