caching

package
v0.0.0-...-d0596f5 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func NewCache

func NewCache(addr string) *Cache

NewCache creates a new cache.

func (*Cache) Delete

func (c *Cache) Delete(key string) error

Delete clears the specified key from the cache.

func (*Cache) Get

func (c *Cache) Get(key string, o Cacheable) error

Get retrieves a Cacheable's data from the cache and calls the cacheable's DeserializeSelf function.

func (*Cache) Has

func (c *Cache) Has(key string) bool

Has returns true if the provided key is in the cache.

func (*Cache) Set

func (c *Cache) Set(key string, o Cacheable, expires time.Duration) error

Set serializes the provided Cacheable and saves it to the cache for the provided amount of time.

type Cacheable

type Cacheable interface {
	// SerializeSelf directs a cacheable object to serialize itself for caching.
	SerializeSelf() ([]byte, error)

	// DeserializeSelf directs a cacheable object to restore itself from the
	// provided string created with SerializeSelf.
	DeserializeSelf([]byte) error
}

Jump to

Keyboard shortcuts

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