All Projects → kristoff-it → zig-okredis

kristoff-it / zig-okredis

Licence: MIT license
Zero-allocation Client for Redis 6+

Programming Languages

Zig
133 projects

Projects that are alternatives of or similar to zig-okredis

Redis3m
A C++ Redis client
Stars: ✭ 173 (+26.28%)
Mutual labels:  redis-client
MythRedisClient
🏎️使用JavaFx做的Redis客户端,资源消耗略大 200-300m,想复用核心代码做成web端,然后浏览器操作,开发起来和跑起来也快
Stars: ✭ 26 (-81.02%)
Mutual labels:  redis-client
scala-redis
A scala library for connecting to a redis server, or a cluster of redis nodes using consistent hashing on the client side.
Stars: ✭ 1,016 (+641.61%)
Mutual labels:  redis-client
Cachingframework.redis
Distributed caching based on StackExchange.Redis and Redis. Includes support for tagging and is cluster-compatible.
Stars: ✭ 209 (+52.55%)
Mutual labels:  redis-client
RedisDrive
This is a.Net redis integrated driver to support a single instance, cluster, sentinel and other modes of data manipulation 这是一个.net 的redis集成驱动,支持单实例、云集群、哨兵等模式的数据操作
Stars: ✭ 19 (-86.13%)
Mutual labels:  redis-client
redisbloom-go
Go Client for RedisBloom probabilistic module
Stars: ✭ 74 (-45.99%)
Mutual labels:  redis-client
Acl
Server framework and network components written by C/C++ for Linux, Mac, FreeBSD, Solaris(x86), Windows, Android, IOS
Stars: ✭ 2,113 (+1442.34%)
Mutual labels:  redis-client
node-cache-manager-redis-store
Redis store for node-cache-manager using node_redis.
Stars: ✭ 117 (-14.6%)
Mutual labels:  redis-client
lib mysqludf redis
Provides Mysql UDF commands to synchronize data from Mysql to Redis.
Stars: ✭ 20 (-85.4%)
Mutual labels:  redis-client
redis-patterns-console
An interactive (and reactive) console to try and go into the deep of Redis and its patterns!
Stars: ✭ 22 (-83.94%)
Mutual labels:  redis-client
Pottery
Redis for humans. 🌎🌍🌏
Stars: ✭ 204 (+48.91%)
Mutual labels:  redis-client
Collectd
The system statistics collection daemon. Please send Pull Requests here!
Stars: ✭ 2,700 (+1870.8%)
Mutual labels:  redis-client
racket-redis
Fast, idiomatic Redis bidings for Racket.
Stars: ✭ 30 (-78.1%)
Mutual labels:  redis-client
Servicestack.redis
.NET's leading C# Redis Client
Stars: ✭ 2,236 (+1532.12%)
Mutual labels:  redis-client
node-redis
A high-performance Node.js Redis client.
Stars: ✭ 15,783 (+11420.44%)
Mutual labels:  redis-client
Go Rejson
Golang client for redislabs' ReJSON module with support for multilple redis clients (redigo, go-redis)
Stars: ✭ 164 (+19.71%)
Mutual labels:  redis-client
aedis
An async redis client designed for performance and scalability
Stars: ✭ 118 (-13.87%)
Mutual labels:  redis-client
TRedisWire
Delphi Redis connector
Stars: ✭ 17 (-87.59%)
Mutual labels:  redis-client
The-Overly-Complicated-Random-Number-Generator
An Overly Complex Random Number Generator, created to demystify how containers work.
Stars: ✭ 25 (-81.75%)
Mutual labels:  redis-client
redis-rs
Redis client for Rust.
Stars: ✭ 25 (-81.75%)
Mutual labels:  redis-client

OkRedis

OkRedis is a zero-allocation client for Redis 6+

Handy and Efficient

OkRedis aims to offer an interface with great ergonomics without compromising on performance or flexibility.

Project status

OkRedis is currently in alpha. The main features are mostly complete, but a lot of polishing is still required.

Everything mentioned in the docs is already implemented and you can just zig run example.zig to quickly see what it can do. Remember OkRedis only supports Redis 6 and above.

Zero dynamic allocations, unless explicitly wanted

The client has two main interfaces to send commands: send and sendAlloc. Following Zig's mantra of making dynamic allocations explicit, only sendAlloc can allocate dynamic memory, and only does so by using a user-provided allocator.

The way this is achieved is by making good use of RESP3's typed responses and Zig's metaprogramming facilities. The library uses compile-time reflection to specialize down to the parser level, allowing OkRedis to decode whenever possible a reply directly into a function frame, without any intermediate dynamic allocation. If you want more information about Zig's comptime:

By using sendAlloc you can decode replies with arbrirary shape at the cost of occasionally performing dynamic allocations. The interface takes an allocator as input, so the user can setup custom allocation schemes such as arenas.

Quickstart

const std = @import("std");
const okredis = @import("./src/okredis.zig");
const SET = okredis.commands.strings.SET;
const OrErr = okredis.types.OrErr;
const Client = okredis.Client;

pub fn main() !void {
    const addr = try std.net.Address.parseIp4("127.0.0.1", 6379);
    var connection = try std.net.tcpConnectToAddress(addr);
    
    var client: Client = undefined;
    try client.init(connection);
    defer client.close();

    // Basic interface
    try client.send(void, .{ "SET", "key", "42" });
    const reply = try client.send(i64, .{ "GET", "key" });
    if (reply != 42) @panic("out of towels");


    // Command builder interface
    const cmd = SET.init("key", "43", .NoExpire, .IfAlreadyExisting);
    const otherReply = try client.send(OrErr(void), cmd);
    switch (otherReply) {
        .Nil => @panic("command should not have returned nil"),
        .Err => @panic("command should not have returned an error"),
        .Ok => std.debug.print("success!", .{}),
    }
}

Available Documentation

The reference documentation is available here.

Extending OkRedis

If you are a Lua script or Redis module author, you might be interested in reading the final sections of COMMANDS.md and REPLIES.md.

Embedding OkRedis in a higher level language

Take a look at the final section of REPLIES.md.

TODOS

  • Implement remaining command builders
  • Better connection management (ipv6, unixsockets, ...)
  • Streamline design of Zig errors
  • Refine support for async/await and think about connection pooling
  • Refine the Redis traits
  • Pub/Sub
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].