momento

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 21 Imported by: 8

Documentation

Overview

Package momento represents API CacheClient interface accessors including control/data operations, errors, operation requests and responses for the SDK.

Package momento represents API CacheClient interface accessors including control/data operations, errors, operation requests and responses for the SDK.

Package momento represents API CacheClient interface accessors including control/data operations, errors, operation requests and responses for the SDK.

Index

Constants

View Source
const (
	// InvalidArgumentError occurs when an invalid argument is passed to Momento client.
	InvalidArgumentError = "InvalidArgumentError"
	// InternalServerError occurs when an unexpected error is encountered while trying to fulfill the request.
	InternalServerError = "InternalServerError"
	// ClientSdkError occurs when a client side error happens.
	ClientSdkError = "ClientSdkError"
	// BadRequestError occurs when a request was invalid.
	BadRequestError = "BadRequestError"
	// CanceledError occurs when a request was cancelled by the server.
	CanceledError = "CanceledError"
	// TimeoutError occurs when an operation did not complete in time.
	TimeoutError = "TimeoutError"
	// PermissionError occurs when there are insufficient permissions to perform operation.
	PermissionError = "PermissionError"
	// AuthenticationError occurs when invalid authentication credentials to connect to cache service are provided.
	AuthenticationError = "AuthenticationError"
	// LimitExceededError occurs when request rate, bandwidth, or object size exceeded the limits for the account.
	LimitExceededError = "LimitExceededError"
	// NotFoundError occurs when a cache with specified name doesn't exist.
	NotFoundError = "NotFoundError"
	// AlreadyExistsError occurs when a cache with specified name already exists.
	AlreadyExistsError = "AlreadyExistsError"
	// UnknownServiceError occurs when an unknown error has occurred.
	UnknownServiceError = "UnknownServiceError"
	// ServerUnavailableError occurs when the server was unable to handle the request.
	ServerUnavailableError = "ServerUnavailableError"
	// FailedPreconditionError occurs when the system is not in a state required for the operation's execution.
	FailedPreconditionError = "FailedPreconditionError"
	// ConnectionError occurs when there is an error connecting to Momento servers.
	ConnectionError = "ConnectionError"
)

Momento Error codes

Variables

View Source
var AllDataReadWrite = &Permissions{
	Permissions: []Permission{
		TopicPermission{Topic: AllTopics{}, Cache: AllCaches{}, Role: PublishSubscribe},
		CachePermission{Cache: AllCaches{}, Role: ReadWrite},
	},
}

Functions

This section is empty.

Types

type AllCacheItems added in v1.14.0

type AllCacheItems struct{}

func (AllCacheItems) IsCacheItemSelector added in v1.14.0

func (AllCacheItems) IsCacheItemSelector()

type AllCaches added in v1.14.0

type AllCaches struct{}

func (AllCaches) CacheName added in v1.14.0

func (AllCaches) CacheName() string

func (AllCaches) IsAllCaches added in v1.14.0

func (AllCaches) IsAllCaches() bool

type AllTopics added in v1.14.0

type AllTopics struct{}

func (AllTopics) IsAllTopics added in v1.14.0

func (AllTopics) IsAllTopics() bool

func (AllTopics) TopicName added in v1.14.0

func (AllTopics) TopicName() string

type AuthClient added in v1.14.0

type AuthClient interface {
	GenerateDisposableToken(ctx context.Context, request *GenerateDisposableTokenRequest) (responses.GenerateDisposableTokenResponse, error)

	Close()
}

func NewAuthClient added in v1.14.0

func NewAuthClient(authConfiguration config.AuthConfiguration, credentialProvider auth.CredentialProvider) (AuthClient, error)

NewAuthClient returns a new AuthClient with provided configuration and credential provider arguments.

type BatchSetItem added in v1.19.0

type BatchSetItem struct {
	Key   Key
	Value Value
}

Type to hold key-value pairs to set in a batch set request.

type Bytes added in v0.6.0

type Bytes []byte

Bytes plain old []byte

type CacheClient added in v0.11.0

type CacheClient interface {
	Logger() logger.MomentoLogger

	// CreateCache Creates a cache if it does not exist.
	CreateCache(ctx context.Context, request *CreateCacheRequest) (responses.CreateCacheResponse, error)
	// DeleteCache deletes a cache and all the items within it.
	DeleteCache(ctx context.Context, request *DeleteCacheRequest) (responses.DeleteCacheResponse, error)
	// ListCaches lists all caches.
	ListCaches(ctx context.Context, request *ListCachesRequest) (responses.ListCachesResponse, error)

	// Increment adds an integer quantity to a field value.
	Increment(ctx context.Context, r *IncrementRequest) (responses.IncrementResponse, error)
	// Set sets the value in cache with a given time to live (TTL)
	Set(ctx context.Context, r *SetRequest) (responses.SetResponse, error)
	// SetIfNotExists sets the value in cache with a given time to live (TTL) if key is not already present
	//
	// Deprecated: Use SetIfAbsent instead.
	SetIfNotExists(ctx context.Context, r *SetIfNotExistsRequest) (responses.SetIfNotExistsResponse, error)
	// SetIfAbsent sets the value in cache with a given time to live (TTL) if key is not already present
	SetIfAbsent(ctx context.Context, r *SetIfAbsentRequest) (responses.SetIfAbsentResponse, error)
	// SetIfPresent sets the value in cache with a given time to live (TTL) if key is present
	SetIfPresent(ctx context.Context, r *SetIfPresentRequest) (responses.SetIfPresentResponse, error)
	// SetIfPresentAndNotEqual sets the value in cache with a given time to live (TTL) if key is present and its value is not equal to the given value
	SetIfPresentAndNotEqual(ctx context.Context, r *SetIfPresentAndNotEqualRequest) (responses.SetIfPresentAndNotEqualResponse, error)
	// SetIfEqual sets the value in cache with a given time to live (TTL) if key is present and its value is equal to the given value
	SetIfEqual(ctx context.Context, r *SetIfEqualRequest) (responses.SetIfEqualResponse, error)
	// SetIfAbsentOrEqual sets the value in cache with a given time to live (TTL) if key is present and its value is equal to the given value
	SetIfAbsentOrEqual(ctx context.Context, r *SetIfAbsentOrEqualRequest) (responses.SetIfAbsentOrEqualResponse, error)
	// SetIfNotEqual sets the value in cache with a given time to live (TTL) if key is present and its value is not equal to the given value
	SetIfNotEqual(ctx context.Context, r *SetIfNotEqualRequest) (responses.SetIfNotEqualResponse, error)
	// SetBatch sets multiple values in cache with a given time to live (TTL)
	SetBatch(ctx context.Context, r *SetBatchRequest) (responses.SetBatchResponse, error)
	// Get gets the cache value stored for the given key.
	Get(ctx context.Context, r *GetRequest) (responses.GetResponse, error)
	// GetBatch gets the cache values stored for the given keys.
	GetBatch(ctx context.Context, r *GetBatchRequest) (responses.GetBatchResponse, error)
	// Delete removes the key from the cache.
	Delete(ctx context.Context, r *DeleteRequest) (responses.DeleteResponse, error)
	// KeysExist checks if provided keys exist in the cache.
	KeysExist(ctx context.Context, r *KeysExistRequest) (responses.KeysExistResponse, error)
	// ItemGetType returns the type of the key in the cache
	ItemGetType(ctx context.Context, r *ItemGetTypeRequest) (responses.ItemGetTypeResponse, error)
	// ItemGetTtl returns the TTL for a key in the cache
	ItemGetTtl(ctx context.Context, r *ItemGetTtlRequest) (responses.ItemGetTtlResponse, error)

	// SortedSetFetchByRank fetches the elements in the given sorted set by rank.
	SortedSetFetchByRank(ctx context.Context, r *SortedSetFetchByRankRequest) (responses.SortedSetFetchResponse, error)
	// SortedSetFetchByScore fetches the elements in the given sorted set by score.
	SortedSetFetchByScore(ctx context.Context, r *SortedSetFetchByScoreRequest) (responses.SortedSetFetchResponse, error)
	// SortedSetPutElement adds an element to the given sorted set. If the element already exists,
	// its score is updated. Creates the sorted set if it does not exist.
	SortedSetPutElement(ctx context.Context, r *SortedSetPutElementRequest) (responses.SortedSetPutElementResponse, error)
	// SortedSetPutElements adds elements to the given sorted set. If an element already exists,
	// its score is updated. Creates the sorted set if it does not exist.
	SortedSetPutElements(ctx context.Context, r *SortedSetPutElementsRequest) (responses.SortedSetPutElementsResponse, error)
	// SortedSetGetScore looks up the score of an element in the sorted set, by the value of the elements.
	SortedSetGetScore(ctx context.Context, r *SortedSetGetScoreRequest) (responses.SortedSetGetScoreResponse, error)
	// SortedSetGetScores looks up the scores of multiple elements in the sorted set, by the value of the elements.
	SortedSetGetScores(ctx context.Context, r *SortedSetGetScoresRequest) (responses.SortedSetGetScoresResponse, error)
	// SortedSetRemoveElement removes an element from the sorted set.
	SortedSetRemoveElement(ctx context.Context, r *SortedSetRemoveElementRequest) (responses.SortedSetRemoveElementResponse, error)
	// SortedSetRemoveElements removes elements from the sorted set.
	SortedSetRemoveElements(ctx context.Context, r *SortedSetRemoveElementsRequest) (responses.SortedSetRemoveElementsResponse, error)
	// SortedSetGetRank looks up the rank of an element in the sorted set, by the value of the element.
	SortedSetGetRank(ctx context.Context, r *SortedSetGetRankRequest) (responses.SortedSetGetRankResponse, error)
	// SortedSetLength gets the number of elements in the sorted set.
	SortedSetLength(ctx context.Context, r *SortedSetLengthRequest) (responses.SortedSetLengthResponse, error)
	// SortedSetLengthByScore gets the number of elements in the sorted set by an optional score range.
	SortedSetLengthByScore(ctx context.Context, r *SortedSetLengthByScoreRequest) (responses.SortedSetLengthByScoreResponse, error)
	// SortedSetIncrementScore increments the score of an element in the sorted set.
	SortedSetIncrementScore(ctx context.Context, r *SortedSetIncrementScoreRequest) (responses.SortedSetIncrementScoreResponse, error)

	// SetAddElement adds an element to the given set. Creates the set if it does not already exist.
	SetAddElement(ctx context.Context, r *SetAddElementRequest) (responses.SetAddElementResponse, error)
	// SetAddElements adds multiple elements to the given set. Creates the set if it does not already exist.
	SetAddElements(ctx context.Context, r *SetAddElementsRequest) (responses.SetAddElementsResponse, error)
	// SetFetch fetches the requested set.
	SetFetch(ctx context.Context, r *SetFetchRequest) (responses.SetFetchResponse, error)
	// SetLength gets the number of elements in the set.
	SetLength(ctx context.Context, r *SetLengthRequest) (responses.SetLengthResponse, error)
	// SetRemoveElement removes an element from the given set.
	SetRemoveElement(ctx context.Context, r *SetRemoveElementRequest) (responses.SetRemoveElementResponse, error)
	// SetRemoveElements removes multiple elements from the set.
	SetRemoveElements(ctx context.Context, r *SetRemoveElementsRequest) (responses.SetRemoveElementsResponse, error)
	// SetContainsElements checks if provided elements are in the given set.
	SetContainsElements(ctx context.Context, r *SetContainsElementsRequest) (responses.SetContainsElementsResponse, error)
	// SetPop removes and returns a given number of elements from the given set.
	SetPop(ctx context.Context, r *SetPopRequest) (responses.SetPopResponse, error)

	// ListPushFront adds an element to the front of the given list. Creates the list if it does not already exist.
	ListPushFront(ctx context.Context, r *ListPushFrontRequest) (responses.ListPushFrontResponse, error)
	// ListPushBack adds an element to the back of the given list. Creates the list if it does not already exist.
	ListPushBack(ctx context.Context, r *ListPushBackRequest) (responses.ListPushBackResponse, error)
	// ListPopFront gets and removes the first value from the given list.
	ListPopFront(ctx context.Context, r *ListPopFrontRequest) (responses.ListPopFrontResponse, error)
	// ListPopBack gets and removes the last value from the given list.
	ListPopBack(ctx context.Context, r *ListPopBackRequest) (responses.ListPopBackResponse, error)
	// ListConcatenateFront adds multiple elements to the front of the given list. Creates the list if it does not already exist.
	ListConcatenateFront(ctx context.Context, r *ListConcatenateFrontRequest) (responses.ListConcatenateFrontResponse, error)
	// ListConcatenateBack adds multiple elements to the back of the given list. Creates the list if it does not already exist.
	ListConcatenateBack(ctx context.Context, r *ListConcatenateBackRequest) (responses.ListConcatenateBackResponse, error)
	// ListFetch fetches all elements of the given list.
	ListFetch(ctx context.Context, r *ListFetchRequest) (responses.ListFetchResponse, error)
	// ListLength gets the number of elements in the given list.
	ListLength(ctx context.Context, r *ListLengthRequest) (responses.ListLengthResponse, error)
	// ListRemoveValue removes all elements from the given list equal to the given value.
	ListRemoveValue(ctx context.Context, r *ListRemoveValueRequest) (responses.ListRemoveValueResponse, error)

	// DictionarySetField adds an element to the given dictionary. Creates the dictionary if it does not already exist.
	DictionarySetField(ctx context.Context, r *DictionarySetFieldRequest) (responses.DictionarySetFieldResponse, error)
	// DictionarySetFields adds multiple elements to the given dictionary. Creates the dictionary if it does not already exist.
	//  Use momento.DictionaryElementsFromMap to help construct the Request from a map object.
	DictionarySetFields(ctx context.Context, r *DictionarySetFieldsRequest) (responses.DictionarySetFieldsResponse, error)
	// DictionaryFetch fetches all elements of the given dictionary.
	DictionaryFetch(ctx context.Context, r *DictionaryFetchRequest) (responses.DictionaryFetchResponse, error)
	// DictionaryLength gets the number of items in the given dictionary.
	DictionaryLength(ctx context.Context, r *DictionaryLengthRequest) (responses.DictionaryLengthResponse, error)
	// DictionaryGetField gets the value stored for the given dictionary and field.
	DictionaryGetField(ctx context.Context, r *DictionaryGetFieldRequest) (responses.DictionaryGetFieldResponse, error)
	// DictionaryGetFields gets multiple values from the given dictionary.
	DictionaryGetFields(ctx context.Context, r *DictionaryGetFieldsRequest) (responses.DictionaryGetFieldsResponse, error)
	// DictionaryIncrement adds an integer quantity to a dictionary value.
	// Incrementing the value of a missing field sets the value to amount.
	DictionaryIncrement(ctx context.Context, r *DictionaryIncrementRequest) (responses.DictionaryIncrementResponse, error)
	// DictionaryRemoveField removes an element from the given dictionary.
	// Performs a no-op if the dictionary or field does not exist.
	DictionaryRemoveField(ctx context.Context, r *DictionaryRemoveFieldRequest) (responses.DictionaryRemoveFieldResponse, error)
	// DictionaryRemoveFields removes multiple fields from the given dictionary.
	// Performs a no-op if the dictionary or fields do not exist.
	DictionaryRemoveFields(ctx context.Context, r *DictionaryRemoveFieldsRequest) (responses.DictionaryRemoveFieldsResponse, error)

	// UpdateTtl overwrites the TTL for key to the provided value.
	UpdateTtl(ctx context.Context, r *UpdateTtlRequest) (responses.UpdateTtlResponse, error)
	// IncreaseTtl sets the TTL for a key to the provided value only if it would increase the existing TTL.
	IncreaseTtl(ctx context.Context, r *IncreaseTtlRequest) (responses.IncreaseTtlResponse, error)
	// DecreaseTtl sets the TTL for a key to the provided value only if it would decrease the existing TTL.
	DecreaseTtl(ctx context.Context, r *DecreaseTtlRequest) (responses.DecreaseTtlResponse, error)

	// Ping pings the cache endpoint to check if the service is up and running.
	Ping(ctx context.Context) (responses.PingResponse, error)

	Close()
}

func NewCacheClient added in v0.11.0

func NewCacheClient(configuration config.Configuration, credentialProvider auth.CredentialProvider, defaultTtl time.Duration) (CacheClient, error)

NewCacheClient returns a new CacheClient with provided configuration, credential provider, and default TTL seconds arguments.

func NewCacheClientWithDefaultCache added in v1.1.0

func NewCacheClientWithDefaultCache(configuration config.Configuration, credentialProvider auth.CredentialProvider, defaultTtl time.Duration, cacheName string) (CacheClient, error)

func NewCacheClientWithEagerConnectTimeout added in v1.8.0

func NewCacheClientWithEagerConnectTimeout(configuration config.Configuration, credentialProvider auth.CredentialProvider, defaultTtl time.Duration, eagerConnectTimeout time.Duration) (CacheClient, error)

NewCacheClientWithEagerConnectTimeout returns a new CacheClient with provided configuration, credential provider, and default TTL seconds arguments, as well as eagerly attempting to establish gRPC connections. A value of 0 for eagerConnectTimeout indicates no eager connections.

type CacheClientProps added in v0.11.0

type CacheClientProps struct {
	CacheName string
	// Configuration to use for logging, transport, retries, and middlewares.
	Configuration config.Configuration
	// CredentialProvider Momento credential provider.
	CredentialProvider  auth.CredentialProvider
	DefaultTtl          time.Duration
	EagerConnectTimeout time.Duration
}

type CacheItemKey added in v1.14.0

type CacheItemKey struct {
	Key []byte
}

func (CacheItemKey) IsCacheItemSelector added in v1.14.0

func (CacheItemKey) IsCacheItemSelector()

type CacheItemKeyPrefix added in v1.14.0

type CacheItemKeyPrefix struct {
	KeyPrefix []byte
}

func (CacheItemKeyPrefix) IsCacheItemSelector added in v1.14.0

func (CacheItemKeyPrefix) IsCacheItemSelector()

type CacheItemSelector added in v1.14.0

type CacheItemSelector interface {
	IsCacheItemSelector()
}

type CacheName added in v1.14.0

type CacheName struct {
	Name string
}

func (CacheName) CacheName added in v1.14.0

func (c CacheName) CacheName() string

func (CacheName) IsAllCaches added in v1.14.0

func (CacheName) IsAllCaches() bool

type CachePermission added in v1.14.0

type CachePermission struct {
	Role  CacheRole
	Cache CacheSelector
}

func (CachePermission) IsPermission added in v1.14.0

func (CachePermission) IsPermission()

type CacheRole added in v1.14.0

type CacheRole int64
const (
	ReadWrite CacheRole = iota
	ReadOnly
	WriteOnly
)

type CacheSelector added in v1.14.0

type CacheSelector interface {
	IsAllCaches() bool
	CacheName() string
}

type CreateCacheRequest

type CreateCacheRequest struct {
	// string used to create a cache.
	CacheName string
}

type DecreaseTtlRequest added in v0.12.0

type DecreaseTtlRequest struct {
	// Name of the cache to get the item from to be deleted
	CacheName string
	// string or byte key to be used to store item.
	Key Key
	// Time to live that you want to decrease to.
	Ttl time.Duration
	// contains filtered or unexported fields
}

type DeleteCacheRequest

type DeleteCacheRequest struct {
	// string cache name to delete.
	CacheName string
}

type DeleteRequest added in v0.8.0

type DeleteRequest struct {
	// Name of the cache to get the item from to be deleted
	CacheName string
	// string or byte key to be used to delete the item.
	Key Key
	// contains filtered or unexported fields
}

type DictionaryElement added in v0.12.0

type DictionaryElement struct {
	Field, Value Value
}

Type to hold field/value elements in dictionaries for use with DictionarySetFields. Field and Value are both Value type which allows both Strings and Bytes.

func DictionaryElementsFromMap added in v0.15.1

func DictionaryElementsFromMap(theMap map[string]string) []DictionaryElement

DictionaryElementsFromMap converts a map[string]string to an array of momento DictionaryElements.

DictionaryElements are used as input to DictionarySetFields.

func DictionaryElementsFromMapStringBytes added in v0.15.1

func DictionaryElementsFromMapStringBytes(theMap map[string][]byte) []DictionaryElement

DictionaryElementsFromMapStringBytes converts a map[string][]byte to an array of momento DictionaryElements.

DictionaryElements are used as input to DictionarySetFields.

func DictionaryElementsFromMapStringString added in v0.15.1

func DictionaryElementsFromMapStringString(theMap map[string]string) []DictionaryElement

DictionaryElementsFromMapStringString converts a map[string]string to an array of momento DictionaryElements.

DictionaryElements are used as input to DictionarySetFields.

func DictionaryElementsFromMapStringValue added in v0.15.1

func DictionaryElementsFromMapStringValue(theMap map[string]Value) []DictionaryElement

DictionaryElementsFromMapStringValue converts a map[string]momento.Value to an array of momento DictionaryElements.

DictionaryElements are used as input to DictionarySetFields.

type DictionaryFetchRequest added in v0.10.0

type DictionaryFetchRequest struct {
	CacheName      string
	DictionaryName string
	// contains filtered or unexported fields
}

type DictionaryGetFieldRequest added in v0.10.0

type DictionaryGetFieldRequest struct {
	CacheName      string
	DictionaryName string
	Field          Value
}

type DictionaryGetFieldsRequest added in v0.10.0

type DictionaryGetFieldsRequest struct {
	CacheName      string
	DictionaryName string
	Fields         []Value
	// contains filtered or unexported fields
}

type DictionaryIncrementRequest added in v0.10.0

type DictionaryIncrementRequest struct {
	CacheName      string
	DictionaryName string
	Field          Value
	Amount         int64
	Ttl            *utils.CollectionTtl
	// contains filtered or unexported fields
}

type DictionaryLengthRequest added in v1.7.0

type DictionaryLengthRequest struct {
	CacheName      string
	DictionaryName string
	// contains filtered or unexported fields
}

type DictionaryRemoveFieldRequest added in v0.10.0

type DictionaryRemoveFieldRequest struct {
	CacheName      string
	DictionaryName string
	Field          Value
}

type DictionaryRemoveFieldsRequest added in v0.10.0

type DictionaryRemoveFieldsRequest struct {
	CacheName      string
	DictionaryName string
	Fields         []Value
	// contains filtered or unexported fields
}

type DictionarySetFieldRequest added in v0.10.0

type DictionarySetFieldRequest struct {
	CacheName      string
	DictionaryName string
	Field          Value
	Value          Value
	Ttl            *utils.CollectionTtl
}

type DictionarySetFieldsRequest added in v0.10.0

type DictionarySetFieldsRequest struct {
	CacheName      string
	DictionaryName string
	Elements       []DictionaryElement
	Ttl            *utils.CollectionTtl
	// contains filtered or unexported fields
}

DictionarySetFieldsRequest represents a request to store multiple elements in a Dictionary.

Use momento.DictionaryElementsFromMap to help construct the Request from a map object.

type DisposableTokenCachePermission added in v1.14.0

type DisposableTokenCachePermission struct {
	Role  CacheRole
	Cache CacheSelector
	Item  CacheItemSelector
}

func (DisposableTokenCachePermission) IsPermission added in v1.14.0

func (DisposableTokenCachePermission) IsPermission()

type DisposableTokenCachePermissions added in v1.14.0

type DisposableTokenCachePermissions struct {
	Permissions []DisposableTokenCachePermission
}

func (DisposableTokenCachePermissions) IsDisposableTokenScope added in v1.14.0

func (DisposableTokenCachePermissions) IsDisposableTokenScope()

type DisposableTokenProps added in v1.14.0

type DisposableTokenProps struct {
	TokenId *string
}

type DisposableTokenScope added in v1.14.0

type DisposableTokenScope interface {
	IsDisposableTokenScope()
}

func CacheKeyPrefixReadOnly added in v1.14.0

func CacheKeyPrefixReadOnly(selector CacheSelector, keyPrefix Value) DisposableTokenScope

func CacheKeyPrefixReadWrite added in v1.14.0

func CacheKeyPrefixReadWrite(selector CacheSelector, keyPrefix Value) DisposableTokenScope

func CacheKeyPrefixWriteOnly added in v1.14.0

func CacheKeyPrefixWriteOnly(selector CacheSelector, keyPrefix Value) DisposableTokenScope

func CacheKeyReadOnly added in v1.14.0

func CacheKeyReadOnly(selector CacheSelector, key Value) DisposableTokenScope

func CacheKeyReadWrite added in v1.14.0

func CacheKeyReadWrite(selector CacheSelector, key Value) DisposableTokenScope

func CacheKeyWriteOnly added in v1.14.0

func CacheKeyWriteOnly(selector CacheSelector, key Value) DisposableTokenScope

func TopicNamePrefixPublishOnly added in v1.14.0

func TopicNamePrefixPublishOnly(selector CacheSelector, topicNamePrefix string) DisposableTokenScope

func TopicNamePrefixPublishSubscribe added in v1.14.0

func TopicNamePrefixPublishSubscribe(selector CacheSelector, topicNamePrefix string) DisposableTokenScope

func TopicNamePrefixSubscribeOnly added in v1.14.0

func TopicNamePrefixSubscribeOnly(selector CacheSelector, topicNamePrefix string) DisposableTokenScope

type Field added in v1.4.0

type Field = Value

Field Type alias to future proof passing in keys.

type GenerateDisposableTokenRequest added in v1.14.0

type GenerateDisposableTokenRequest struct {
	ExpiresIn utils.ExpiresIn
	Scope     DisposableTokenScope
	Props     DisposableTokenProps
}

type GetBatchRequest added in v1.19.0

type GetBatchRequest struct {
	CacheName string
	Keys      []Value
	// contains filtered or unexported fields
}

type GetRequest added in v0.8.0

type GetRequest struct {
	// Name of the cache to get the item from
	CacheName string
	// string or byte key to be used to store item
	Key Key
	// contains filtered or unexported fields
}

type IncreaseTtlRequest added in v0.12.0

type IncreaseTtlRequest struct {
	// Name of the cache to get the item from to be deleted
	CacheName string
	// string or byte key to be used to store item.
	Key Key
	// Time to live that you want to increase to.
	Ttl time.Duration
	// contains filtered or unexported fields
}

type IncrementRequest added in v1.4.0

type IncrementRequest struct {
	CacheName string
	Field     Field
	Amount    int64
	Ttl       *utils.CollectionTtl
	// contains filtered or unexported fields
}

type ItemGetTtlRequest added in v1.4.0

type ItemGetTtlRequest struct {
	CacheName string
	Key       Key
	// contains filtered or unexported fields
}

type ItemGetTypeRequest added in v1.4.0

type ItemGetTypeRequest struct {
	CacheName string
	Key       Key
	// contains filtered or unexported fields
}

type Key added in v0.9.0

type Key = Value

Key Type alias to future proof passing in keys.

type KeysExistRequest added in v0.12.0

type KeysExistRequest struct {
	CacheName string
	Keys      []Key
	// contains filtered or unexported fields
}

type Leaderboard added in v1.20.0

type Leaderboard interface {
	// Delete removes all elements from the leaderboard.
	Delete(ctx context.Context) (responses.LeaderboardDeleteResponse, error)

	// FetchByRank gets all elements that fall within the specified min and max ranks.
	FetchByRank(ctx context.Context, request LeaderboardFetchByRankRequest) (responses.LeaderboardFetchResponse, error)

	// FetchByScore gets elements that fall within the specified min and max scores. Elements with the same score
	// will be returned in alphanumerical order based on their ID (e.g. IDs of elements with the same score would be
	// returned in the order [1, 10, 123, 2, 234, ...] rather than [1, 2, 10, 123, 234, ...]).
	FetchByScore(ctx context.Context, request LeaderboardFetchByScoreRequest) (responses.LeaderboardFetchResponse, error)

	// GetRank fetches elements (with their rank, score, and ID) given a list of element IDs.
	GetRank(ctx context.Context, request LeaderboardGetRankRequest) (responses.LeaderboardFetchResponse, error)

	// Length gets the number of entries in the leaderboard.
	Length(ctx context.Context) (responses.LeaderboardLengthResponse, error)

	// RemoveElements deletes elements with the specified IDs from the leaderboard.
	RemoveElements(ctx context.Context, request LeaderboardRemoveElementsRequest) (responses.LeaderboardRemoveElementsResponse, error)

	// Upsert inserts elements if they do not already exist in the leaderboard and updates elements if they do
	// already exist. There are no partial failures; an upsert call will either succeed or fail.
	Upsert(ctx context.Context, request LeaderboardUpsertRequest) (responses.LeaderboardUpsertResponse, error)
}

Leaderboard defines the set of operations that can be performed on a leaderboard object.

type LeaderboardFetchByRankRequest added in v1.20.0

type LeaderboardFetchByRankRequest struct {
	StartRank uint32
	EndRank   uint32
	Order     *LeaderboardOrder
}

type LeaderboardFetchByScoreRequest added in v1.20.0

type LeaderboardFetchByScoreRequest struct {
	MinScore *float64
	MaxScore *float64
	Order    *LeaderboardOrder
	Offset   *uint32
	Count    *uint32
}

type LeaderboardGetRankRequest added in v1.20.0

type LeaderboardGetRankRequest struct {
	Ids   []uint32
	Order *LeaderboardOrder
}

type LeaderboardInternalDeleteRequest added in v1.20.0

type LeaderboardInternalDeleteRequest struct {
	CacheName       string
	LeaderboardName string
}

type LeaderboardInternalFetchByRankRequest added in v1.20.0

type LeaderboardInternalFetchByRankRequest struct {
	CacheName       string
	LeaderboardName string
	StartRank       uint32
	EndRank         uint32
	Order           *LeaderboardOrder
}

type LeaderboardInternalFetchByScoreRequest added in v1.20.0

type LeaderboardInternalFetchByScoreRequest struct {
	CacheName       string
	LeaderboardName string
	MinScore        *float64
	MaxScore        *float64
	Order           *LeaderboardOrder
	Offset          *uint32
	Count           *uint32
}

type LeaderboardInternalGetRankRequest added in v1.20.0

type LeaderboardInternalGetRankRequest struct {
	CacheName       string
	LeaderboardName string
	Ids             []uint32
	Order           *LeaderboardOrder
}

type LeaderboardInternalLengthRequest added in v1.20.0

type LeaderboardInternalLengthRequest struct {
	CacheName       string
	LeaderboardName string
}

type LeaderboardInternalRemoveElementsRequest added in v1.20.0

type LeaderboardInternalRemoveElementsRequest struct {
	CacheName       string
	LeaderboardName string
	Ids             []uint32
}

type LeaderboardInternalUpsertRequest added in v1.20.0

type LeaderboardInternalUpsertRequest struct {
	CacheName       string
	LeaderboardName string
	Elements        []LeaderboardUpsertElement
}

type LeaderboardOrder added in v1.20.0

type LeaderboardOrder = SortedSetOrder

type LeaderboardRemoveElementsRequest added in v1.20.0

type LeaderboardRemoveElementsRequest struct {
	Ids []uint32
}

type LeaderboardRequest added in v1.20.0

type LeaderboardRequest struct {
	CacheName       string
	LeaderboardName string
}

type LeaderboardUpsertElement added in v1.20.0

type LeaderboardUpsertElement struct {
	Id    uint32
	Score float64
}

type LeaderboardUpsertRequest added in v1.20.0

type LeaderboardUpsertRequest struct {
	Elements []LeaderboardUpsertElement
}

type ListCachesRequest

type ListCachesRequest struct {
	// Token to continue paginating through the list. It's used to handle large paginated lists.
	NextToken string
}

type ListConcatenateBackRequest added in v0.8.0

type ListConcatenateBackRequest struct {
	CacheName           string
	ListName            string
	Values              []Value
	TruncateFrontToSize uint32
	Ttl                 *utils.CollectionTtl
	// contains filtered or unexported fields
}

type ListConcatenateFrontRequest added in v0.8.0

type ListConcatenateFrontRequest struct {
	CacheName          string
	ListName           string
	Values             []Value
	TruncateBackToSize uint32
	Ttl                *utils.CollectionTtl
	// contains filtered or unexported fields
}

type ListFetchRequest added in v0.8.0

type ListFetchRequest struct {
	CacheName  string
	ListName   string
	StartIndex *int32
	EndIndex   *int32
	// contains filtered or unexported fields
}

type ListLengthRequest added in v0.8.0

type ListLengthRequest struct {
	CacheName string
	ListName  string
	// contains filtered or unexported fields
}

type ListPopBackRequest added in v0.8.0

type ListPopBackRequest struct {
	CacheName string
	ListName  string
	// contains filtered or unexported fields
}

type ListPopFrontRequest added in v0.8.0

type ListPopFrontRequest struct {
	CacheName string
	ListName  string
	// contains filtered or unexported fields
}

type ListPushBackRequest added in v0.8.0

type ListPushBackRequest struct {
	CacheName           string
	ListName            string
	Value               Value
	TruncateFrontToSize uint32
	Ttl                 *utils.CollectionTtl
	// contains filtered or unexported fields
}

type ListPushFrontRequest added in v0.8.0

type ListPushFrontRequest struct {
	CacheName          string
	ListName           string
	Value              Value
	TruncateBackToSize uint32
	Ttl                *utils.CollectionTtl
	// contains filtered or unexported fields
}

type ListRemoveValueRequest added in v0.8.0

type ListRemoveValueRequest struct {
	CacheName string
	ListName  string
	Value     Value
	// contains filtered or unexported fields
}

type MomentoError added in v0.2.0

type MomentoError interface {
	// Satisfy the generic error interface.
	error
	// Code Returns Momento Error codes.
	Code() string
	// Message Returns the error details message.
	Message() string
	// OriginalErr Returns the original error if one was set.  Nil is returned if not set.
	OriginalErr() error
}

func NewMomentoError added in v0.2.0

func NewMomentoError(code string, message string, originalErr error) MomentoError

NewMomentoError returns an initialized MomentoError wrapper.

type Permission added in v1.14.0

type Permission interface {
	IsPermission()
}

type PermissionScope added in v1.14.0

type PermissionScope interface {
	IsPermissionScope()
}

type Permissions added in v1.14.0

type Permissions struct {
	Permissions []Permission
}

func CacheReadOnly added in v1.14.0

func CacheReadOnly(selector CacheSelector) Permissions

func CacheReadWrite added in v1.14.0

func CacheReadWrite(selector CacheSelector) Permissions

func CacheWriteOnly added in v1.14.0

func CacheWriteOnly(selector CacheSelector) Permissions

func TopicPublishOnly added in v1.14.0

func TopicPublishOnly(cacheSelector CacheSelector, topicSelector TopicSelector) Permissions

func TopicPublishSubscribe added in v1.14.0

func TopicPublishSubscribe(cacheSelector CacheSelector, topicSelector TopicSelector) Permissions

func TopicSubscribeOnly added in v1.14.0

func TopicSubscribeOnly(cacheSelector CacheSelector, topicSelector TopicSelector) Permissions

func (Permissions) IsDisposableTokenScope added in v1.14.0

func (Permissions) IsDisposableTokenScope()

func (Permissions) IsPermissionScope added in v1.14.0

func (Permissions) IsPermissionScope()

type PreviewLeaderboardClient added in v1.20.0

type PreviewLeaderboardClient interface {
	// Leaderboard creates a new leaderboard object in a given cache with the provided leaderboard name.
	Leaderboard(ctx context.Context, request *LeaderboardRequest) (Leaderboard, error)
	// Close will shut down the leaderboard client and related resources.
	Close()
}

func NewPreviewLeaderboardClient added in v1.20.0

func NewPreviewLeaderboardClient(leaderboardConfiguration config.LeaderboardConfiguration, credentialProvider auth.CredentialProvider) (PreviewLeaderboardClient, error)

NewPreviewLeaderboardClient creates a new instance of a Preview Leaderboard Client.

type SetAddElementRequest added in v0.10.0

type SetAddElementRequest struct {
	CacheName string
	SetName   string
	Element   Value
	Ttl       *utils.CollectionTtl
}

type SetAddElementsRequest added in v0.10.0

type SetAddElementsRequest struct {
	CacheName string
	SetName   string
	Elements  []Value
	Ttl       *utils.CollectionTtl
	// contains filtered or unexported fields
}

type SetBatchRequest added in v1.19.0

type SetBatchRequest struct {
	CacheName string
	Items     []BatchSetItem
	Ttl       time.Duration
	// contains filtered or unexported fields
}

type SetContainsElementsRequest added in v0.12.0

type SetContainsElementsRequest struct {
	CacheName string
	SetName   string
	Elements  []Value
	// contains filtered or unexported fields
}

type SetFetchRequest added in v0.10.0

type SetFetchRequest struct {
	CacheName string
	SetName   string
	// contains filtered or unexported fields
}

type SetIfAbsentOrEqualRequest added in v1.17.0

type SetIfAbsentOrEqualRequest struct {
	// Name of the cache to store the item in.
	CacheName string
	// string or byte key to be used to store item.
	Key Key
	// string ot byte value to be stored.
	Value Value
	// string or byte value to compare with the existing value in the cache.
	Equal Value
	// Optional Time to live in cache in seconds.
	// If not provided, then default TTL for the cache client instance is used.
	Ttl time.Duration
	// contains filtered or unexported fields
}

type SetIfAbsentRequest added in v1.17.0

type SetIfAbsentRequest struct {
	// Name of the cache to store the item in.
	CacheName string
	// string or byte key to be used to store item.
	Key Key
	// string ot byte value to be stored.
	Value Value
	// Optional Time to live in cache in seconds.
	// If not provided, then default TTL for the cache client instance is used.
	Ttl time.Duration
	// contains filtered or unexported fields
}

type SetIfEqualRequest added in v1.17.0

type SetIfEqualRequest struct {
	// Name of the cache to store the item in.
	CacheName string
	// string or byte key to be used to store item.
	Key Key
	// string ot byte value to be stored.
	Value Value
	// string or byte value to compare with the existing value in the cache.
	Equal Value
	// Optional Time to live in cache in seconds.
	// If not provided, then default TTL for the cache client instance is used.
	Ttl time.Duration
	// contains filtered or unexported fields
}

type SetIfNotEqualRequest added in v1.17.0

type SetIfNotEqualRequest struct {
	// Name of the cache to store the item in.
	CacheName string
	// string or byte key to be used to store item.
	Key Key
	// string ot byte value to be stored.
	Value Value
	// string or byte value to compare with the existing value in the cache.
	NotEqual Value
	// Optional Time to live in cache in seconds.
	// If not provided, then default TTL for the cache client instance is used.
	Ttl time.Duration
	// contains filtered or unexported fields
}

type SetIfNotExistsRequest added in v1.7.0

type SetIfNotExistsRequest struct {
	// Name of the cache to store the item in.
	CacheName string
	// string or byte key to be used to store item.
	Key Key
	// string ot byte value to be stored.
	Value Value
	// Optional Time to live in cache in seconds.
	// If not provided, then default TTL for the cache client instance is used.
	Ttl time.Duration
	// contains filtered or unexported fields
}

type SetIfPresentAndNotEqualRequest added in v1.17.0

type SetIfPresentAndNotEqualRequest struct {
	// Name of the cache to store the item in.
	CacheName string
	// string or byte key to be used to store item.
	Key Key
	// string ot byte value to be stored.
	Value Value
	// string or byte value to compare with the existing value in the cache.
	NotEqual Value
	// Optional Time to live in cache in seconds.
	// If not provided, then default TTL for the cache client instance is used.
	Ttl time.Duration
	// contains filtered or unexported fields
}

type SetIfPresentRequest added in v1.17.0

type SetIfPresentRequest struct {
	// Name of the cache to store the item in.
	CacheName string
	// string or byte key to be used to store item.
	Key Key
	// string ot byte value to be stored.
	Value Value
	// Optional Time to live in cache in seconds.
	// If not provided, then default TTL for the cache client instance is used.
	Ttl time.Duration
	// contains filtered or unexported fields
}

type SetLengthRequest added in v1.7.0

type SetLengthRequest struct {
	CacheName string
	SetName   string
	// contains filtered or unexported fields
}

type SetPopRequest added in v1.12.0

type SetPopRequest struct {
	CacheName string
	SetName   string
	Count     *uint32
	// contains filtered or unexported fields
}

type SetRemoveElementRequest added in v0.10.0

type SetRemoveElementRequest struct {
	CacheName string
	SetName   string
	Element   Value
}

type SetRemoveElementsRequest added in v0.10.0

type SetRemoveElementsRequest struct {
	CacheName string
	SetName   string
	Elements  []Value
	// contains filtered or unexported fields
}

type SetRequest added in v0.8.0

type SetRequest struct {
	// Name of the cache to store the item in.
	CacheName string
	// string or byte key to be used to store item.
	Key Key
	// string ot byte value to be stored.
	Value Value
	// Optional Time to live in cache in seconds.
	// If not provided, then default TTL for the cache client instance is used.
	Ttl time.Duration
	// contains filtered or unexported fields
}

type SortedSetElement added in v0.8.0

type SortedSetElement struct {
	Value Value
	Score float64
}

func SortedSetElementsFromMap added in v0.15.1

func SortedSetElementsFromMap(theMap map[string]float64) []SortedSetElement

SortedSetElementsFromMap converts a map[string]float64 to an array of momento SortedSetElements.

SortedSetElements are used as input to SortedSetPutElements.

type SortedSetFetchByRankRequest added in v0.16.0

type SortedSetFetchByRankRequest struct {
	CacheName string
	SetName   string
	Order     SortedSetOrder
	StartRank *int32
	EndRank   *int32
	// contains filtered or unexported fields
}

type SortedSetFetchByScoreRequest added in v0.16.0

type SortedSetFetchByScoreRequest struct {
	CacheName string
	SetName   string
	Order     SortedSetOrder
	MinScore  *float64
	MaxScore  *float64
	Offset    *uint32
	Count     *uint32
	// contains filtered or unexported fields
}

type SortedSetGetRankRequest added in v0.8.0

type SortedSetGetRankRequest struct {
	CacheName string
	SetName   string
	Value     Value
	Order     SortedSetOrder
	// contains filtered or unexported fields
}

type SortedSetGetScoreRequest added in v0.8.0

type SortedSetGetScoreRequest struct {
	CacheName string
	SetName   string
	Value     Value
}

type SortedSetGetScoresRequest added in v0.11.0

type SortedSetGetScoresRequest struct {
	CacheName string
	SetName   string
	Values    []Value
	// contains filtered or unexported fields
}

type SortedSetIncrementScoreRequest added in v0.9.0

type SortedSetIncrementScoreRequest struct {
	CacheName string
	SetName   string
	Value     Value
	Amount    float64
	Ttl       *utils.CollectionTtl
	// contains filtered or unexported fields
}

type SortedSetLengthByScoreRequest added in v1.7.0

type SortedSetLengthByScoreRequest struct {
	CacheName string
	SetName   string
	MinScore  *float64
	MaxScore  *float64
	// contains filtered or unexported fields
}

type SortedSetLengthRequest added in v1.7.0

type SortedSetLengthRequest struct {
	CacheName string
	SetName   string
	// contains filtered or unexported fields
}

type SortedSetOrder added in v0.8.0

type SortedSetOrder int
const (
	ASCENDING  SortedSetOrder = 0
	DESCENDING SortedSetOrder = 1
)

type SortedSetPutElementRequest added in v0.15.0

type SortedSetPutElementRequest struct {
	CacheName string
	SetName   string
	Value     Value
	Score     float64
	Ttl       *utils.CollectionTtl
}

type SortedSetPutElementsRequest added in v0.14.0

type SortedSetPutElementsRequest struct {
	CacheName string
	SetName   string
	Elements  []SortedSetElement
	Ttl       *utils.CollectionTtl
	// contains filtered or unexported fields
}

type SortedSetRemoveElementRequest added in v0.15.0

type SortedSetRemoveElementRequest struct {
	CacheName string
	SetName   string
	Value     Value
}

type SortedSetRemoveElementsRequest added in v0.14.0

type SortedSetRemoveElementsRequest struct {
	CacheName string
	SetName   string
	Values    []Value
	// contains filtered or unexported fields
}

type String added in v0.9.0

type String string

String string type that will be converted to []byte

type TopicClient added in v0.11.0

type TopicClient interface {
	Subscribe(ctx context.Context, request *TopicSubscribeRequest) (TopicSubscription, error)
	Publish(ctx context.Context, request *TopicPublishRequest) (responses.TopicPublishResponse, error)

	Close()
}

func NewTopicClient added in v0.11.0

func NewTopicClient(topicsConfiguration config.TopicsConfiguration, credentialProvider auth.CredentialProvider) (TopicClient, error)

NewTopicClient returns a new TopicClient with provided configuration and credential provider arguments.

type TopicName added in v1.14.0

type TopicName struct {
	Name string
}

func (TopicName) IsAllTopics added in v1.14.0

func (TopicName) IsAllTopics() bool

func (TopicName) TopicName added in v1.14.0

func (t TopicName) TopicName() string

type TopicNamePrefix added in v1.14.0

type TopicNamePrefix struct {
	NamePrefix string
}

func (TopicNamePrefix) IsAllTopics added in v1.14.0

func (TopicNamePrefix) IsAllTopics() bool

func (TopicNamePrefix) TopicName added in v1.14.0

func (t TopicNamePrefix) TopicName() string

type TopicPermission added in v1.14.0

type TopicPermission struct {
	Role  TopicRole
	Cache CacheSelector
	Topic TopicSelector
}

func (TopicPermission) IsPermission added in v1.14.0

func (TopicPermission) IsPermission()

type TopicPublishRequest added in v0.8.0

type TopicPublishRequest struct {
	CacheName string
	TopicName string
	Value     TopicValue
}

type TopicRole added in v1.14.0

type TopicRole int64
const (
	PublishSubscribe TopicRole = iota
	SubscribeOnly
	PublishOnly
)

type TopicSelector added in v1.14.0

type TopicSelector interface {
	IsAllTopics() bool
	TopicName() string
}

type TopicSubscribeRequest added in v0.8.0

type TopicSubscribeRequest struct {
	CacheName                   string
	TopicName                   string
	ResumeAtTopicSequenceNumber uint64
}

type TopicSubscription added in v0.8.0

type TopicSubscription interface {
	Item(ctx context.Context) (TopicValue, error)
	Close()
}

type TopicValue added in v0.8.0

type TopicValue interface {
	// contains filtered or unexported methods
}

TopicValue For now, topics take the same types as normal methods. In the future this might not be so, topics might take different types than methods.

The TopicValue interface alias future proofs us. Topics still take the normal String and Bytes, but in the future we can add types that other methods might not take.

type UpdateTtlRequest added in v0.12.0

type UpdateTtlRequest struct {
	// Name of the cache to get the item from to be deleted
	CacheName string
	// string or byte key to be used to store item.
	Key Key
	// Time to live that you want to update in cache in seconds.
	Ttl time.Duration
	// contains filtered or unexported fields
}

type Value added in v0.9.0

type Value interface {
	// contains filtered or unexported methods
}

Value Interface to help users deal with passing us values as strings or bytes. Value: momento.Bytes([]bytes("abc")) Value: momento.String("abc")

Source Files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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