Set API reference for Momento Cache
A set is a collection of elements, but each element can appear only once and order is not guaranteed.
Example: if your set contains [1, 2, 3]
and you add 2, the set remains [1, 2, 3].
See Sets for more information on their usage.
Set methods
SetAddElement
Adds an element to a set. If the set item does not already exist, this method will create one.
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache. |
setName | String | Name of the set item to be altered. |
element | String | bytes | Element to be added by this operation. |
ttl | CollectionTTL object | TTL for the set item in cache. This TTL takes precedence over the TTL used when initializing a cache connection client. |
Method response object
- Success
- Error
See response objects for specific information.
SetAddElements
Adds multiple elements to a set item.
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache. |
setName | String | Name of the set item to be altered. |
elements | String[] | bytes[] | Elements to be added by this operation. |
ttl | CollectionTTL object | TTL for the set item in cache. This TTL takes precedence over the TTL used when initializing a cache connection client. |
Method response object
- Success
- Error
See response objects for specific information.
SetFetch
Gets a set item from a cache.
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache. |
setName | String | The name of the set item to be retreived. |
Method response object
The response object for SetFetch returns three possible options, a cache hit, miss, or an error.
- Hit
- valueSetBytes(): bytes[]
- valueSetString(): string[]
- toString(): string
- Miss
- Error
See response objects for specific information.
SetRemoveElement
Removes a single element from an existing set item.
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache. |
setName | String | Name of the set item to be altered. |
element | String | bytes | Element to be removed by this operation. |
Method response object
- Success
- Error
See response objects for specific information.
SetRemoveElements
Removes multiple elements from an existing set item.
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache. |
setName | String | Name of the set item to be altered. |
element | String | bytes | Element to be removed by this operation. |
Method response object
- Success
- Error
See response objects for specific information.
SetContainsElement
Checks if a provided element is in the given set.
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache. |
setName | String | Name of the set item. |
element | String | bytes | Name of the element to check existence of. |
Method response object
The response object for SetContainsElement returns three possible options, a cache hit, miss, or an error.
- Hit
- containsElement(): bool
- Miss
- Error
See response objects for specific information.
SetContainsElements
Checks if provided elements are in the given set.
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache. |
setName | String | Name of the set item. |
elements | String[] \ | bytes |
Method response object
The response object for SetContainsElements returns three possible options, a cache hit, miss, or an error.
- Hit
- containsElements(): bool[]
- Miss
- Error
See response objects for specific information.