Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // AnyVersion is a special version number that can be used to // indicate that the version of a cache entry does not matter. // The Get function will return any cached value, regardless of // its version and will generate a new value if there is no cached // value. AnyVersion = CacheVersion{/* contains filtered or unexported fields */} // NonCachedVersion is a special version number that can be used to // indicate to the Get function that we want to generate a new value // and do not want to use any cached value. NonCachedVersion = CacheVersion{/* contains filtered or unexported fields */} )
Functions ¶
func IsNewerVersion ¶
func IsNewerVersion(a, b CacheVersion) bool
Types ¶
type AtomicLatestVersion ¶
type AtomicLatestVersion struct {
// contains filtered or unexported fields
}
AtomicLatestVersion is a thread-safe version bookkeeper, which can be used to keep track of the latest version of a set of results. For example, if a piece of code performs 5 cache lookups, this AtomicLatestVersion can be used to keep track of the latest version of the results of those lookups and use that latest version as the version of the combined result. Then, the next time the code runs, it can invalidate all the cache lookups by specifying the latest version as the minimum version for each individual cache lookup. TODO: this mechanism might introduce some unnecessary cache invalidations.
func NewAtomicLatestVersion ¶
func NewAtomicLatestVersion(rv CacheVersion) AtomicLatestVersion
func (*AtomicLatestVersion) Load ¶
func (r *AtomicLatestVersion) Load() CacheVersion
func (*AtomicLatestVersion) Update ¶
func (r *AtomicLatestVersion) Update(rv CacheVersion)
type CacheVersion ¶
type CacheVersion struct {
// contains filtered or unexported fields
}
CacheVersion is a version number that can be used to track the version of a cache entry. The version number is a monotonically increasing number that is globally unique across all caches and entries.
func NewGlobalVersion ¶
func NewGlobalVersion() CacheVersion
func NextVersion ¶
func NextVersion(rv CacheVersion) CacheVersion