Skip to main content

KV Admin SDK

Use the Admin SDK when your backend or worker needs programmatic access to a declared KV namespace.

KV still keeps Cloudflare's eventual-consistency model and 1 write-per-second limit on the same key, so avoid using it for hot counters or transactional state.

Available Methods

MethodPurpose
get(key)Read a value by key
set(key, value, { ttl? })Write a value with optional TTL
list({ prefix?, limit?, cursor? })List keys with pagination
delete(key)Remove a key

Language Method Matrix

The operation set is the same across SDKs. The main differences are naming conventions such as Async, capitalization, or Elixir bang variants.

LanguageMethodsNotes
TypeScript / JavaScriptget, set, list, deleteSame names in the JS admin SDK
Dartget, set, list, deleteUses named ttl: on set(...)
Kotlinget, set, list, deletesuspend methods
Javaget, set, list, deleteOverloads for set(...) and list()
Scalaget, set, list, deleteScala wrapper around Java admin SDK
Pythonget, set, list, deletettl= keyword on set(...)
GoGet, Set, List, DeleteContext-first method signatures
PHPget, set, list, deleteOptional nullable params
Rustget, set, list, deleteAsync methods on the client
C#GetAsync, SetAsync, ListAsync, DeleteAsyncCancellationToken optional
Rubyget, set, list, deleteRuby keyword args for optional params
Elixirget, get!, set, set!, list, list!, delete, delete!! variants unwrap {:ok, ...}
import { createAdminClient } from '@edge-base/admin';

const admin = createAdminClient('https://your-app.example.com', {
serviceKey: process.env.EDGEBASE_SERVICE_KEY!,
});

await admin.kv('cache').set('user:123', 'cached-data', { ttl: 300 });
const value = await admin.kv('cache').get('user:123');
const keys = await admin.kv('cache').list({ prefix: 'user:' });

Delete a Key

KV delete support is available in the Admin SDK. The method name is delete across SDKs.

await admin.kv('cache').delete('user:123');

Use this for cache invalidation, one-time tokens, or cleanup jobs. Keep in mind that KV is eventually consistent, so other regions may briefly observe stale reads right after deletion.