Crates.io | redis-grpc |
lib.rs | redis-grpc |
version | 0.0.4 |
source | src |
created_at | 2021-10-01 15:21:02.675978 |
updated_at | 2021-10-01 17:02:37.16008 |
description | gRPC bridging for redis |
homepage | |
repository | |
max_upload_size | |
id | 459153 |
size | 22,594,023 |
redis gRPC proxy
USAGE:
redis-grpc [OPTIONS]
FLAGS:
--help Print help information
-V, --version Print version information
OPTIONS:
-h, --host <HOST> Target redis host to proxy from
-p, --port <PORT> Listen on port
redis-grpc -h redis://localhost:10400 -p 50051
Supports keys
get
set
subscribe
channel
and arbitrary command (response casted to string)
yarn install redis-grpc
or npm install redis-grpc
/// JavaScript / TypeScript
import { RedisGrpcPromiseClient } from 'redis-grpc/gen-js/redis_grpc_grpc_web_pb';
import { KeysRequest, SetRequest } from 'redis-grpc/gen-js/redis_grpc_pb';
const perform_set = () => {
const client = new RedisGrpcPromiseClient("http://localhost:50051");
/// support TypeScript
let req = new SetRequest();
req.setKey("key")
req.setValue("value");
client.set(req)
.then(resp => console.log(resp.getResult()))
.catch(console.error)
}
/// Subscribe channels
const sub_request = new SubscribeRequest();
sub_request.setChannelsList(["channel:1", "channel:2"]);
const stream = client.subscribe(sub_request);
stream.on('data', (data: SubscribeResponse) => {
console.log({
message: data.getMessage(),
channel: data.getChannel(),
})
})
/// Publish channel
const pub_request = new PublishRequest();
pub_request.setChannel("channel:1")
await client.publish(pub_request);
This repository is licensed under the "MIT" license. See LICENSE.