#key-value-store #key-value #wasmcloud #capability #redis #api-bindings


Interface for wasmCloud actors to access Key-Value stores (wasmcloud:keyvalue)

19 releases (10 breaking)

0.12.0 Sep 19, 2023
0.11.0 Jul 20, 2023
0.10.0 Apr 12, 2023
0.9.1 Nov 23, 2022
0.3.0 Oct 24, 2021

#422 in Database interfaces

Download history 15/week @ 2024-03-14 23/week @ 2024-03-28 10/week @ 2024-04-04 200/week @ 2024-04-18 69/week @ 2024-04-25 2/week @ 2024-05-02 49/week @ 2024-05-09 9/week @ 2024-05-16 10/week @ 2024-05-23 30/week @ 2024-05-30 136/week @ 2024-06-06

139 downloads per month

Apache-2.0 and maybe LGPL-3.0-or-later


crates.io  TinyGo Version

wasmCloud Key Value Interface

This is the key-value interface with the contract ID of wasmcloud:keyvalue. This interface defines a set of common operations for interacting with key-value stores.

Note that things like consistency guarantees, backup, failover support, replications, and more are all concerns specific to individual providers and not the interface itself.

Capability Provider Implementations

The following is a list of implementations of the wasmcloud:keyvalue contract. Feel free to submit a PR adding your implementation if you have a community/open source version.

Name Vendor Description
Redis wasmCloud wasmCloud key-value provider for the Redis database
Vault wasmCloud wasmCloud key-value provider for the Hashicorp Vault secrets engine.

Example Usage

🦀 Rust

Check if a value exists in the kvstore

use wasmbus_rpc::actor::prelude::Context;
use wasmcloud_interface_keyvalue::{KeyValue, KeyValueSender};

async fn key_exists(ctx: &Context, key: &str) -> bool {
    KeyValueSender::new().contains(ctx, key).await.is_ok()

Increment a numeric value

use wasmbus_rpc::actor::prelude::*;
use wasmcloud_interface_keyvalue::{IncrementRequest, KeyValue, KeyValueSender};
/// increment the counter by the amount, returning the new value
async fn increment_counter(ctx: &Context, key: String, value: i32) -> RpcResult<i32> {
    let new_val = KeyValueSender::new()
        .increment(ctx, &IncrementRequest { key, value })

🐭 Golang

Check if a value exists in the kvstore

import "github.com/wasmcloud/actor-tinygo"
import keyvalue "github.com/wasmcloud/interfaces/keyvalue/tinygo"

func KeyExists(ctx *actor.Context, key string) (bool, error){
   client := keyvalue.NewProviderKeyValue()
   return client.Contains(ctx, key)

Increment a numeric value

import "github.com/wasmcloud/actor-tinygo"
import keyvalue "github.com/wasmcloud/interfaces/keyvalue/tinygo"

func IncrementCounter(ctx *actor.Context, key string, value int32) (int32, error) {
   client := keyvalue.NewProviderKeyValue()
   return client.Increment(ctx, keyvalue.IncrementRequest{key, value})


~505K SLoC