memory

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2021 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const NoExpiration time.Duration = -1

NoExpiration is used to indicate that data should not expire from the cache.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemoryStore

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

MemoryStore is used to create an in-memory cache.

func NewMemoryStore

func NewMemoryStore(cleanupInterval time.Duration) *MemoryStore

NewMemoryStore creates an in-memory cache where the expired items are deleted based on the cleanupInterval duration.

func NewMemoryStoreFrom

func NewMemoryStoreFrom(cache *cache.Cache) *MemoryStore

NewMemoryStoreFrom creates an in-memory cache directly from a *cache.Cache object.

func (*MemoryStore) Close

func (c *MemoryStore) Close()

Close returns the connection back to the pool for storage drivers that utilize a pool. For this driver, it does nothing.

func (*MemoryStore) Conn

func (c *MemoryStore) Conn(ctx context.Context) (remember.Cacher, error)

Conn does nothing for this storage driver.

func (*MemoryStore) Forget

func (c *MemoryStore) Forget(key string) error

Forget clears the value from the cache for the particular key.

func (*MemoryStore) ForgetAll

func (c *MemoryStore) ForgetAll() error

ForgetAll clears all values from the cache.

func (*MemoryStore) Get

func (c *MemoryStore) Get(key string) (_ interface{}, found bool, _ error)

Get returns a value from the cache if the key exists.

func (*MemoryStore) Set

func (c *MemoryStore) Set(key string, expiration time.Duration, itemToStore interface{}) error

Set sets a item into the cache for a particular key.

func (*MemoryStore) StorePointer

func (c *MemoryStore) StorePointer() bool

StorePointer sets whether a storage driver requires itemToStore to be stored as a pointer or as a concrete value.

Jump to

Keyboard shortcuts

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