Skip to content

cxKV

Auto-generated documentation from JSDoc comments

cxKV

Key Value Store, Globally Synced Atomic and Eventually Consistent

Example

import { kv, ko } from 'cxKV';

export async function main(data) {
  await kv.set('hello', 'world');
  await ko.set('record', { hello: 'world' });

  let a = await kv.get('hello');
  let b = await ko.get('record');

  return { a, b };
}

Kind: global class

cxKV.incr(key, [value], [ttl]) ⇒ Promise.<number>

Increment a numeric value atomically

Kind: static method of cxKV
Returns: Promise.<number> - The new value after incrementing

Param Type Default Description
key string The key to increment
[value] number 1 The amount to increment by (can be negative to decrement)
[ttl] number 0 Time to live in seconds (0 = no expiration)

Example

const newValue = await incr('counter');
const decremented = await incr('counter', -1);
const withExpiry = await incr('daily_count', 1, 86400);

cxKV.usage() ⇒ Promise.<number>

Get current storage usage in bytes

Kind: static method of cxKV
Returns: Promise.<number> - Current storage usage in bytes
Example

const currentUsage = await usage();
console.log(`Using ${currentUsage} bytes`);

cxKV.quota() ⇒ Promise.<object>

Get Quota

Kind: static method of cxKV
Returns: Promise.<object> - The quota information including limits and current usage
Example

const quotaInfo = await quota();
console.log('Storage limit:', quotaInfo.limit);

cxKV.keys() ⇒ Promise.<Array.<string>>

Get all keys in the store

Kind: static method of cxKV
Returns: Promise.<Array.<string>> - Array of all keys
Example

const allKeys = await keys();
console.log(`Found ${allKeys.length} keys`);