@mathrunet/masamune_cloudflare_kv
v3.2.1
Published
Server-side Masamune package for handling Cloudflare KV.
Maintainers
Readme
[GitHub] | [YouTube] | [Packages] | [X] | [LinkedIn] | [mathru.net]
Just load the package in index.ts and pass the predefined data to the methods to implement the server side.
Also, katana_functions_firebase can be used to execute server-side functions from methods defined on the client side, allowing for safe implementation.
Installation
Install the following packages
npm install @mathrunet/masamune_cloudflare_kvImplementation
Pass the return value of the deploy function to export default. It is defined by passing various Workers to the deploy function.
import * as m from "@mathrunet/masamune_cloudflare_kv";
// Define [m.Functions.xxxx] for the functions to be added to Workers.
//
// Workersに追加する機能を[m.Functions.xxxx]を定義してください。
export default m.deploy([
m.Functions.kv({
bindingName: "MASAMUNE_KV",
}),
]);Add a KV namespace binding to wrangler.jsonc.
{
"kv_namespaces": [
{
"binding": "MASAMUNE_KV",
"id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
]
}The endpoint stores one Masamune document per KV key. The document model path is used as the KV key without conversion.
key: config/app
value: {"maintenance":false,"version":12}Collection reads are Remote Config compatible pseudo reads. GET
/kv/collection/config/app returns the same document under __default__.
Cloudflare KV limits apply. A single value can be up to 25 MiB, and repeated writes to the same key are limited. KV is eventually consistent, so use Turso or TiDB for data that requires immediate consistency or frequent writes.
GitHub Sponsors
Sponsors are always welcome. Thank you for your support!
