@zuplo/runtime 6.54.29 → 6.55.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/esm/index.js +7 -7
- package/out/types/index.d.ts +20 -1
- package/package.json +1 -1
package/out/types/index.d.ts
CHANGED
|
@@ -4801,6 +4801,10 @@ export declare type McpToolHandler<TArgs = any> = (
|
|
|
4801
4801
|
context: ZuploContext
|
|
4802
4802
|
) => Promise<CallToolResult> | CallToolResult;
|
|
4803
4803
|
|
|
4804
|
+
declare interface MemoryCacheOptions {
|
|
4805
|
+
maxSize: number;
|
|
4806
|
+
}
|
|
4807
|
+
|
|
4804
4808
|
/**
|
|
4805
4809
|
* A two-tier cache that combines in-memory caching with zone-level caching.
|
|
4806
4810
|
* Data is first checked in memory cache for fastest access, then falls back to
|
|
@@ -4812,8 +4816,18 @@ export declare type McpToolHandler<TArgs = any> = (
|
|
|
4812
4816
|
* import { MemoryZoneReadThroughCache, ZuploContext } from "@zuplo/runtime";
|
|
4813
4817
|
*
|
|
4814
4818
|
* export async function myHandler(request: ZuploRequest, context: ZuploContext) {
|
|
4819
|
+
* // Create cache with default memory size (1000 items)
|
|
4815
4820
|
* const cache = new MemoryZoneReadThroughCache<UserData>("user-cache", context);
|
|
4816
4821
|
*
|
|
4822
|
+
* // Or create cache with custom memory size (500 items max)
|
|
4823
|
+
* // Note that maxSize controls the number of items in the in-memory cache,
|
|
4824
|
+
* // but does not limit the number of items in the zone cache.
|
|
4825
|
+
* const limitedCache = new MemoryZoneReadThroughCache<UserData>(
|
|
4826
|
+
* "limited-cache",
|
|
4827
|
+
* context,
|
|
4828
|
+
* { maxSize: 500 }
|
|
4829
|
+
* );
|
|
4830
|
+
*
|
|
4817
4831
|
* // Try to get cached data
|
|
4818
4832
|
* const cachedUser = await cache.get("user-123");
|
|
4819
4833
|
* if (cachedUser) {
|
|
@@ -4836,8 +4850,13 @@ export declare class MemoryZoneReadThroughCache<T = unknown> {
|
|
|
4836
4850
|
* Creates a new MemoryZoneReadThroughCache instance.
|
|
4837
4851
|
* @param name - A unique name for this cache instance
|
|
4838
4852
|
* @param context - The ZuploContext from the current request
|
|
4853
|
+
* @param options - Optional configuration for the memory cache
|
|
4839
4854
|
*/
|
|
4840
|
-
constructor(
|
|
4855
|
+
constructor(
|
|
4856
|
+
name: string,
|
|
4857
|
+
context: ZuploContext,
|
|
4858
|
+
options?: MemoryCacheOptions
|
|
4859
|
+
);
|
|
4841
4860
|
/**
|
|
4842
4861
|
* Retrieves a value from the cache by key. First checks memory cache,
|
|
4843
4862
|
* then falls back to zone cache if not found in memory.
|