@agentuity/keyvalue
A standalone package for the Agentuity Key-Value storage service.
Installation
npm install @agentuity/keyvalue
Quick Start
import { KeyValueClient } from '@agentuity/keyvalue';
const client = new KeyValueClient();
await client.set('my-namespace', 'user:123', { name: 'John', email: 'john@example.com' }, {
ttl: 3600
});
const result = await client.get('my-namespace', 'user:123');
if (result.exists) {
console.log('Found:', result.data);
console.log('Content-Type:', result.contentType);
}
await client.delete('my-namespace', 'user:123');
const stats = await client.getStats('my-namespace');
console.log(`${stats.count} keys, ${stats.sum} bytes`);
const results = await client.search('my-namespace', 'user');
Configuration
The client can be configured with options:
const client = new KeyValueClient({
apiKey: 'your-api-key',
url: 'https://api.agentuity.com',
logger: customLogger,
});
Environment Variables
AGENTUITY_SDK_KEY | API key for authentication | Required |
AGENTUITY_REGION | Region for API endpoints | usc |
AGENTUITY_KV_URL | Override KV API URL | Auto-detected |
TTL (Time-to-Live)
Keys can have an optional TTL:
await client.set('ns', 'key', value, { ttl: 3600 });
await client.set('ns', 'key', value, { ttl: null });
await client.set('ns', 'key', value);
License
Apache-2.0