Crates.io | cloudflare-kv-proxy |
lib.rs | cloudflare-kv-proxy |
version | 0.2.0 |
source | src |
created_at | 2022-02-15 16:04:36.857529 |
updated_at | 2022-12-28 11:11:17.796948 |
description | Cloudflare KV Proxy SDK. |
homepage | |
repository | https://github.com/ihciah/cloudflare-kv-proxy |
max_upload_size | |
id | 532790 |
size | 60,635 |
This project is implemented to use Cloudflare KV in non-worker environment.
worker/kv_proxy.js
to create a new Cloudflare Worker using your browser, and click Save and Deploy
.KEY
, the value will be your access token(please make it long enough).#[derive(Serialize, Deserialize, Debug)]
struct Demo {
name: String,
age: u8,
}
let data = Demo {
name: "red".to_string(),
age: 21,
};
let client = Client::new("https://your-proxy.workers.dev", "YOUR-TOKEN").unwrap();
println!("Put string: {:?}", client.put("test_key", "balabala").await);
println!("Get string: {:?}", client.get::<String>("test_key").await);
println!("Put struct: {:?}", client.put("test_key2", &data).await);
println!("Get struct: {:?}", client.get::<Demo>("test_key2").await);
To avoid unnecessary requests to Cloudflare, the proxy caches the response.
By default the caching is enabled. You can set default-features = false
in Cargo.toml
.