Skip to content

Add redis keyvalue plugin support#293

Open
jfleitz wants to merge 4 commits intowasmCloud:mainfrom
jfleitz:jfleitz/redis-keyvalue
Open

Add redis keyvalue plugin support#293
jfleitz wants to merge 4 commits intowasmCloud:mainfrom
jfleitz:jfleitz/redis-keyvalue

Conversation

@jfleitz
Copy link

@jfleitz jfleitz commented Feb 23, 2026

Add Redis backend for wasi:keyvalue and redis-keyvalue example

Summary

  • Implements a Redis-backed wasi:keyvalue plugin (RedisKeyValue) in wash-runtime using the redis crate with a multiplexed async connection. Keys are namespaced per bucket as {identifier}:{key}.
  • Adds wasi_keyvalue_redis_url to DevConfig so projects can opt into the Redis backend via .wash/config.yaml.
  • Wires the Redis backend into wash dev with priority order: Redis → filesystem → in-memory.
  • Adds a new examples/redis-keyvalue project — an HTTP component that stores and retrieves key-value pairs through the wasi:keyvalue/store interface, backed by Redis at runtime.

Changes

Area What changed
crates/wash-runtime New redis.rs plugin; RedisKeyValue::from_url constructor; redis workspace dep
crates/wash/src/config.rs DevConfig.wasi_keyvalue_redis_url: Option<String>
crates/wash/src/cli/dev.rs Redis branch in keyvalue plugin selection
examples/redis-keyvalue/ New self-contained example component with WIT deps, config, and README

Testing

Testing was completed by running a Redis server locally via Docker:

docker run --name redis -p 6379:6379 redis:latest

The example was built and run with wash dev from the examples/redis-keyvalue/ directory. The following curl commands were used to validate correct behaviour:

# Store a key-value pair
curl -X POST http://localhost:8000 \
  -H "Content-Type: application/json" \
  -d '{"key":"mykey","value":"myvalue"}'
# → 200 Stored key 'mykey'

# Retrieve the value
curl "http://localhost:8000?key=mykey"
# → 200 myvalue

# Retrieve a key that does not exist
curl "http://localhost:8000?key=missing"
# → 404 Key 'missing' not found

Signed-off-by: Jeremy Fleitz jeremy@cosmonic.com

Signed-off-by: Jeremy Fleitz <jeremy@cosmonic.com>
@jfleitz jfleitz requested a review from a team as a code owner February 23, 2026 15:19
let redis_key = bucket_handle.prefixed_key(key);
let key = key.clone();
async move {
match conn.get::<_, Option<Vec<u8>>>(redis_key).await {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic wise this is fine, however can we use MGET?

One big redis roundtrip vs many small ones.

The code we have for v1 is for wrpc-bindgen so slightly different signatures https://github.com/wasmCloud/wasmCloud/blob/main/crates/provider-keyvalue-redis/src/lib.rs#L465

@lxfontes
Copy link
Member

This is 99% ✅ 🎉
The only real blocker is the loss of precision u64 -> i64

Signed-off-by: Jeremy Fleitz <jeremy@cosmonic.com>
@jfleitz
Copy link
Author

jfleitz commented Feb 25, 2026

Made updates to use MGET and MSET. I also added a check for u64 numbers that would be truncated/wrapped so that it still meets the WIT spec, but would throw an error if too large.

Retested with the example/redis-keyvalue project.

Signed-off-by: Jeremy Fleitz <jeremy@cosmonic.com>
Signed-off-by: Jeremy Fleitz <jeremy@cosmonic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants