Skip to main content

Fetching Cached Values

You can retrieve previously stored values from a specific cache using the values function under ductape.product.caches.

This is useful when you want to reuse cached data across components or environments, such as responses from API calls or computed values from earlier events.

Usage

import ductape from './ductapeClient';
import { FetchRemoteCachePayload } from '@ductape/sdk/dist/types';

const filters: FetchRemoteCachePayload = {
cache_tag: 'example_cache',
component_tag: 'my_component',
component_type: 'action',
product_tag: 'my_product',
};

const values = await ductape.product.caches.values(filters);

Filter Options

FieldTypeDescription
cache_tagstringThe tag of the cache to query values from.
component_tagstringThe tag of the component that stored the value.
component_typestringThe type of component (action, event, condition, etc).
product_tagstringThe tag of the product (used when working across multiple products).
expiryDateOptional date to filter only non-expired values.

Sample Response

[
{
"key": "user_123_result",
"value": "{\"score\":88}",
"cache_tag": "example_cache",
"product_tag": "my_product",
"component_tag": "score_action",
"component_type": "action",
"expiry": "2025-05-01T00:00:00.000Z"
},
{
"key": "user_124_result",
"value": "{\"score\":92}",
"cache_tag": "example_cache",
"product_tag": "my_product",
"component_tag": "score_action",
"component_type": "action",
"expiry": "2025-05-01T00:00:00.000Z"
}
]

Response Fields

FieldTypeDescription
keystringThe unique key for this cached value.
valuestringThe cached value (typically a stringified object).
cache_tagstringThe tag of the cache this value belongs to.
product_tagstringThe tag of the product where this value was generated.
component_tagstringThe tag of the component (e.g., action or event) that stored the value.
component_typestringThe type of component that generated this value (action, event, etc).
expiryDateThe expiration date of this cache value, if set.