Fetching Cached Values
Retrieve previously stored values from your caches using ductape.cache.values().
Quick Example
- TypeScript
- Java
- Go
- .NET
const values = await ductape.cache.values({
cache_tag: 'api-responses',
});
console.log(values);
Map<String, Object> values = ductape.cache.values(Map.of(
"cache_tag", "api-responses"
));
System.out.println(values);
values := client.cache.values({
"cache_tag": "api-responses",
});
fmt.Println(values);
var values = await ductape.cache.values({
["cache_tag"] = "api-responses",
});
Console.WriteLine(values);
How It Works
Query cached data by specifying filters like cache tag, component tag, or product tag. This is useful for reusing cached API responses or computed values across your application.
Examples
Fetch all values from a cache
- TypeScript
- Java
- Go
- .NET
const values = await ductape.cache.values({
cache_tag: 'user-data',
});
Map<String, Object> values = ductape.cache.values(Map.of(
"cache_tag", "user-data"
));
values := client.cache.values({
"cache_tag": "user-data",
});
var values = await ductape.cache.values({
["cache_tag"] = "user-data",
});
Filter by component
- TypeScript
- Java
- Go
- .NET
const values = await ductape.cache.values({
cache_tag: 'api-responses',
component_tag: 'fetch-user',
component_type: 'action',
});
Map<String, Object> values = ductape.cache.values(Map.of(
"cache_tag", "api-responses",
"component_tag", "fetch-user",
"component_type", "action"
));
values := client.cache.values({
"cache_tag": "api-responses",
"component_tag": "fetch-user",
"component_type": "action",
});
var values = await ductape.cache.values({
["cache_tag"] = "api-responses",
["component_tag"] = "fetch-user",
["component_type"] = "action",
});
Filter non-expired values only
- TypeScript
- Java
- Go
- .NET
const values = await ductape.cache.values({
cache_tag: 'temp-data',
expiry: new Date()
});
Map<String, Object> values = ductape.cache.values(Map.of(
"cache_tag", "temp-data",
expiry: Instant.now()
));
values := client.cache.values({
"cache_tag": "temp-data",
expiry: new Date()
});
var values = await ductape.cache.values({
["cache_tag"] = "temp-data",
expiry: DateTime.UtcNow
});
Response
[
{
"key": "user_123_result",
"value": "{\"score\":88}",
"cache_tag": "api-responses",
"component_tag": "score_action",
"component_type": "action",
"expiry": "2025-05-01T00:00:00.000Z"
}
]
| Field | Description |
|---|---|
key | Unique key for this cached value |
value | The cached value (typically stringified JSON) |
cache_tag | Cache this value belongs to |
product | Product where this value was stored |
component_tag | Component that stored the value |
component_type | Type of component (action, event, etc.) |
expiry | Expiration date, if set |
Reference
Filter Options
- TypeScript
- Java
- Go
- .NET
interface FetchRemoteCachePayload {
cache_tag: string;
product: string;
component_tag?: string;
component_type?: string;
expiry?: Date;
}
interface FetchRemoteCachePayload Map.of(
cache_tag: string;
product: string;
component_tag?: string;
component_type?: string;
expiry?: Date;
)
interface FetchRemoteCachePayload {
cache_tag: string;
product: string;
component_tag?: string;
component_type?: string;
expiry?: Date;
}
interface FetchRemoteCachePayload {
cache_tag: string;
product: string;
component_tag?: string;
component_type?: string;
expiry?: Date;
}