Node.js library to interact with CloudFlare Workers KV.
CloudFlare Workers KV is faster <key, value> storage that runs on top of CloudFlare Network to offer a geo-distributed service almost free or reasonable cheaper.
Use it in combination with CloudFlare Workers or AWS Lambda to have a truly serverless database access, where the value will be serve from the nearest edge node, being the lowest response latency possible.
$ npm install @kikobeats/cloudflare-workers-kv --save
The library is a convenient way to interact with CloudFlare Workers KV via usinng CloudFlare Workers KV API.
const cloudFlareWorkersKV = require('@kikobeats/cloudflare-workers-kv')
const ms = require('ms')
const store = cloudFlareWorkersKV({
accountId: '<Cloudflare-Account-Id>',
email: '<Cloudflare-Email>',
key: '<Cloudflare-API-Key>',
namespaceId: '<Cloudflare-Workers-KV-Namespace-Id>'
})
async function examples () {
// get a value
await store.get('foo')
// set a value forever
await store.set('foo', 'bar', ms('5m'))
// set a value associating with a time-to-live associated
await store.set('foo', 'bar', ms('5m'))
// delete a value
await store.delete('foo')
// delete all values
await store.clear('foo')
}
@kikobeats/cloudflare-workers-kv © Kiko Beats, released under the MIT License.
Authored and maintained by Kiko Beats with help from contributors.
kikobeats.com · GitHub Kiko Beats · Twitter @Kikobeats