cache

package
v5.100.1 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2020 License: AGPL-3.0, Apache-2.0 Imports: 1 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 interface {
	// Purge is used to completely clear the cache.
	Purge()

	// Add adds the given key and value to the store without an expiry.
	Add(key, value interface{})

	// AddWithDefaultExpires adds the given key and value to the store with the default expiry.
	AddWithDefaultExpires(key, value interface{})

	// AddWithExpiresInSecs adds the given key and value to the cache with the given expiry.
	AddWithExpiresInSecs(key, value interface{}, expireAtSecs int64)

	// Get returns the value stored in the cache for a key, or nil if no value is present. The ok result indicates whether value was found in the cache.
	Get(key interface{}) (value interface{}, ok bool)

	// GetOrAdd returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored.
	// This API intentionally deviates from the Add-only variants above for simplicity. We should simplify the entire API in the future.
	GetOrAdd(key, value interface{}, ttl time.Duration) (actual interface{}, loaded bool)

	// Remove deletes the value for a key.
	Remove(key interface{})

	// RemoveByPrefix deletes all keys containing the given prefix string.
	RemoveByPrefix(prefix string)

	// Keys returns a slice of the keys in the cache.
	Keys() []interface{}

	// Len returns the number of items in the cache.
	Len() int

	// Name identifies this cache instance among others in the system.
	Name() string

	// GetInvalidateClusterEvent returns the cluster event configured when this cache was created.
	GetInvalidateClusterEvent() string
}

Cache is a representation of any cache store that has keys and values

type Provider

type Provider interface {
	// Connect opens a new connection to the cache using specific provider parameters.
	Connect()

	// NewCache creates a new cache with given size.
	NewCache(size int) Cache

	// NewCacheWithParams creates a new cache with the given parameters.
	NewCacheWithParams(size int, name string, defaultExpiry int64, invalidateClusterEvent string) Cache

	// Close releases any resources used by the cache provider.
	Close()
}

Provider defines how to create new caches

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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