cache

package
v21.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: Apache-2.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	observer.Observer

	Entry(key string) (*Entry, fail.Error)                     // returns a cache entry from its key
	Reserve(key string, timeout time.Duration) fail.Error      // reserve an entry in the cache
	Commit(key string, content Cacheable) (*Entry, fail.Error) // Commit fills a previously reserved entry by 'key' with 'content'
	Free(key string) fail.Error                                // frees a cache entry (removing the reservation from cache)
	Add(content Cacheable) (*Entry, fail.Error)                // adds a content in cache (doing Reserve+Commit in a whole with content ID as key)
}

Cache interface describing what a struct must implement to be considered as a cache

func NewCache

func NewCache(name string) (Cache, fail.Error)

NewCache creates a new cache

type Cacheable

type Cacheable interface {
	observer.Observable

	Released()  // Tells cache handler the instance is no more used, giving a chance to free this instance from cache
	Destroyed() // tells cache handler the instance has been deleted and MUST be removed from cache
}

Cacheable is the interface a struct must satisfy to be able to be cached

type Entry

type Entry struct {
	observer.Observer
	// contains filtered or unexported fields
}

Entry is a struct containing information about a cache entry

func (*Entry) Content

func (ce *Entry) Content() interface{}

Content returns the content of the cache

func (*Entry) Key

func (ce *Entry) Key() string

Key returns the key of the cache entry

func (*Entry) LockContent

func (ce *Entry) LockContent() uint

LockContent increments the counter of use of cache entry

func (*Entry) LockCount

func (ce *Entry) LockCount() uint

LockCount returns the current count of locks of the content

func (*Entry) UnlockContent

func (ce *Entry) UnlockContent() uint

UnlockContent decrements the counter of use of cache entry

Jump to

Keyboard shortcuts

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