expirable

package module
v0.0.0-...-baf8e43 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2015 License: MIT Imports: 2 Imported by: 20

README

cache

Simple cache with expirable values

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Expirable

type Expirable interface {
	Expired(baseTime time.Time) bool
	Value() interface{}
}

type ExpirableValue

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

func NewExpirableValue

func NewExpirableValue(v interface{}) *ExpirableValue

func NewExpirableValueWithOffset

func NewExpirableValueWithOffset(v interface{}, expiry uint64) *ExpirableValue

func (*ExpirableValue) Expired

func (e *ExpirableValue) Expired(q time.Time) bool

func (*ExpirableValue) Value

func (e *ExpirableValue) Value() interface{}

type KeyValue

type KeyValue struct {
	Key   Keyable
	Value Expirable
}

type Keyable

type Keyable interface{}

type Operation

type Operation int
const (
	Noop Operation = 1 << iota
	Create
	Read
	Update
	Delete
)

type OperationCache

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

func New

func New() *OperationCache

func (*OperationCache) Get

func (oc *OperationCache) Get(k Keyable) (Expirable, bool)

func (*OperationCache) Items

func (oc *OperationCache) Items() chan *KeyValue

func (*OperationCache) Put

func (oc *OperationCache) Put(k Keyable, v Expirable) bool

func (*OperationCache) Remove

func (oc *OperationCache) Remove(k Keyable) (prev Expirable, exist bool)

Jump to

Keyboard shortcuts

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