Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Redic

Redis server/client implementation in C from scratch with no dependencies


description


Running locally

  • Make sure you have make and any C compiler installed on your system.
  • Run git clone git@github.com:WinterCore/redic.git && cd redic
  • To build the project, simply run make
  • And finally, to run the server ./Redic (it will run on port 6969 by default, use --port 7000 to change it)

Interacting with the server

  • You can use any Redis cli or you can just use redis-cli which comes bundled with Redis
  • Don't forget to specify the port of Redic when running commands, eg: redis-cli -p 6969 SET foo bar

Running the tests

  • The suite needs Deno. It builds and launches its own server, so don't start one first.
  • Run deno task test

TODO

  • TCP server with configurable port
  • Concurrent client connections (one thread per client)
  • RESP protocol parser (simple string, bulk string, array, integer, error, null)
  • RESP serializer
  • Actor pattern for data layer — single-threaded data store (septic tank) with lock-free reads/writes via message-passing (sewer channels + ring buffer)
  • TTL stored per key with lazy expiry on access
  • Inline command support (plain-text commands via telnet/netcat)
  • Pipelining (handle multiple commands in a single read)
  • Active expiry — background task that periodically sweeps expired keys
  • Commands
    • PING [message]
    • SET key value [NX|XX] [GET] [EX|PX|EXAT|PXAT|KEEPTTL]
    • GET key
    • DEL key [key ...] (single key for now cuz command parser doesn't support variadic args)
    • TTL key
    • INFO
    • EXISTS key [key ...] (single key for now)
    • EXPIRE key seconds
    • INCR / DECR / INCRBY / DECRBY
    • APPEND key value
    • MGET key [key ...] / MSET key value [key value ...]
    • KEYS pattern
    • TYPE key
    • RENAME key newkey
    • Lists (LPUSH, RPUSH, LPOP, RPOP, LRANGE)
    • Hashes (HSET, HGET, HGETALL, HDEL)
    • Sets (SADD, SREM, SMEMBERS, SISMEMBER)
  • AOF persistence — mutation routing, batched flushing, and fsync'd appends to data.aof are done; still need startup replay, torn-tail recovery, flush-on-shutdown, and compaction
  • Replication — replica handshake (PINGREPLCONFPSYNC), full resync on connect, partial resync via replication backlog after reconnect
  • Transactions — MULTI / EXEC / DISCARD with WATCH for optimistic locking
  • Pub/Sub — SUBSCRIBE / PUBLISH / UNSUBSCRIBE with fan-out to blocking subscribers

About

Redic is a Redis-compatible server in C that uses actor-style message passing (Sewer, Septic Tank, Potty) for serialized in-memory operations and AOF persistence.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages