cache

package
v5.24.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2020 License: AGPL-3.0, Apache-2.0 Imports: 1 Imported by: 15

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 string, value interface{})

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

	// AddWithExpiresInSecs adds the given key and value to the cache with the given expiry.
	AddWithExpiresInSecs(key string, 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 string) (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 string, value interface{}, ttl time.Duration) (actual interface{}, loaded bool)

	// Remove deletes the value for a key.
	Remove(key string)

	// Keys returns a slice of the keys in the cache.
	Keys() []string

	// 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