utils

package
v1.39.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateApiKeyExpiry added in v1.25.0

func ValidateApiKeyExpiry(in ExpiresIn) momentoerrors.MomentoSvcErr

func ValidateDisposableTokenExpiry added in v1.14.0

func ValidateDisposableTokenExpiry(in ExpiresIn) momentoerrors.MomentoSvcErr

func ValidateName added in v1.20.0

func ValidateName(name string, label string) error

Types

type CollectionTtl added in v0.11.0

type CollectionTtl struct {
	// Ttl is the time.Duration after which the cached collection should be expired from the cache.
	// If CollectionTtl is not provided, the default Ttl that was passed to a momento.CacheClient instance is used.
	Ttl time.Duration
	// If RefreshTtl is true, then the collection's Ttl will be refreshed (to prolong the life of the collection) on every update.
	// If false, then the collection's Ttl will only be set when the collection is initially created.
	RefreshTtl bool
}

CollectionTtl represents the desired behavior for managing the Ttl on collection objects (dictionaries, lists, sets, and sorted sets) in your cache. For cache operations that modify a collection, there are a few things to consider. The first time the collection is created, we need to set a Ttl on it. For subsequent operations that modify the collection you may choose to update the Ttl in order to prolong the life of the cached collection object, or you may choose to leave the Ttl unmodified in order to ensure that the collection expires at the original TTL. The default behavior is to refresh the Ttl (to prolong the life of the collection) each time it is written. This behavior can be modified by calling WithNoRefreshTtlOnUpdates.

func FromCacheTtl

func FromCacheTtl() CollectionTtl

FromCacheTtl is the default way to handle Ttls for collections. The default Ttl that was specified when constructing momento.CacheClient will be used, and the Ttl for the collection will be refreshed any time the collection is modified.

func Of

func Of(ttl time.Duration) CollectionTtl

Of constructs a CollectionTtl with the specified time.Duration. Ttl for the collection will be refreshed any time the collection is modified.

func RefreshTtlIfProvided

func RefreshTtlIfProvided(ttl ...time.Duration) CollectionTtl

RefreshTtlIfProvided constructs a CollectionTtl with the specified time.Duration. Will only refresh if the Ttl is provided.

func WithNoRefreshTtlOnUpdates

func WithNoRefreshTtlOnUpdates(currentTtl CollectionTtl) CollectionTtl

WithNoRefreshTtlOnUpdates specifies that the TTL for the collection should not be refreshed when the collection is modified. Use this if you want to ensure that your collection expires at the originally specified time, even if you make modifications to the value of the collection.

func WithRefreshTtlOnUpdates

func WithRefreshTtlOnUpdates(currentTtl CollectionTtl) CollectionTtl

WithRefreshTtlOnUpdates specifies that the TTL for the collection should be refreshed when the collection is modified. (This is the default behavior.)

type Expiration added in v1.14.0

type Expiration interface {
	DoesExpire() bool
}

type ExpiresAt added in v1.25.0

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

ExpiresAt is used in AuthClient responses to specify the expiration time of a disposable token or API key.

func ExpiresAtFromEpoch added in v1.25.0

func ExpiresAtFromEpoch(epoch int64) ExpiresAt

ExpiresAtFromEpoch constructs an ExpiresAt with the specified epoch timestamp, but if timestamp is undefined, the epoch timestamp will be set to math.MaxInt64.

func (ExpiresAt) DoesExpire added in v1.25.0

func (e ExpiresAt) DoesExpire() bool

func (ExpiresAt) Epoch added in v1.25.0

func (e ExpiresAt) Epoch() int64

type ExpiresIn added in v1.14.0

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

ExpiresIn is used in AuthClient requests to specify the expiration time of a disposable token or API key.

func ExpiresAtEpoch added in v1.14.0

func ExpiresAtEpoch(expiresBy int64) ExpiresIn

func ExpiresInDays added in v1.14.0

func ExpiresInDays(days int64) ExpiresIn

func ExpiresInHours added in v1.14.0

func ExpiresInHours(hours int64) ExpiresIn

func ExpiresInMinutes added in v1.14.0

func ExpiresInMinutes(minutes int64) ExpiresIn

func ExpiresInNever added in v1.14.0

func ExpiresInNever() ExpiresIn

func ExpiresInSeconds added in v1.14.0

func ExpiresInSeconds(seconds int64) ExpiresIn

func (ExpiresIn) DoesExpire added in v1.14.0

func (e ExpiresIn) DoesExpire() bool

func (ExpiresIn) Seconds added in v1.14.0

func (e ExpiresIn) Seconds() int64

Jump to

Keyboard shortcuts

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