The HyrexKV class provides static methods for key-value operations:
Copy
Ask AI
import { HyrexKV } from '@hyrex/hyrex';// Set a valueawait HyrexKV.set('user-123', 'John Doe');// Get a valueconst userName = await HyrexKV.get('user-123');console.log(userName); // 'John Doe'
// Store with workflow-specific keysconst workflowKey = `workflow-${ctx.workflowRunId}-temp`;await HyrexKV.set(workflowKey, data);// Consider cleanup in final task// Note: TypeScript SDK doesn't have delete method
Validate Data Size
Copy
Ask AI
const storeData = async (key: string, data: any) => { const serialized = JSON.stringify(data); // Check size before storing (1MB limit) const sizeInBytes = new TextEncoder().encode(serialized).length; if (sizeInBytes > 1024 * 1024) { throw new Error(`Data too large: ${sizeInBytes} bytes`); } await HyrexKV.set(key, serialized);};