store-flows

Crates.iostore-flows
lib.rsstore-flows
version0.3.2
sourcesrc
created_at2023-01-03 07:25:37.105316
updated_at2024-03-07 14:18:04.209604
descriptionStore extension for flows.network
homepage
repository
max_upload_size
id749959
size9,228
DarumaDocker!! (DarumaDocker)

documentation

https://docs.rs/store-flows

README

This is a library for storing key/value in your flow function in flows.network.

Usage example

use serde_json::json;
use lambda_flows::{request_received, send_response};
use store_flows::{get, set, Expire, ExpireKind};

#[no_mangle]
pub fn run() {
    if let Some((_qry, _body)) = request_received() {
      let mut c = match get("count") {
          Some(v) => v.as_u64().unwrap_or_default(),
          None => 0,
      };

      c = c + 1;

      set(
          "count",
          json!(c),
          Some(Expire {
              kind: ExpireKind::Ex,
              value: 20,
          }),
      );

      send_response(
          200,
          vec![(String::from("content-type"), String::from("text/html"))],
          c.to_string().as_bytes().to_vec(),
      );
    }
}

This is a Lambda flow function. It can show the times it has been called. When a request is received, we get the previous count number from store, imcrement it by one, then set it back to store.

The whole document is here.

Commit count: 0

cargo fmt