Skip to content

A Node.js implementation of a Redis‑like in‑memory data store with master–slave replication, persistence, and support for common Redis‑style commands.

Notifications You must be signed in to change notification settings

reyden142/Building-a-Redis-like-In-Memory-Data-Store

Repository files navigation

Building-a-Redis-like-In-Memory-Data-Store

How to Set Up, Run, and Use Your Redis-Like Data Store

  1. Download the Building-a-Redis-like-In-Memory-Data-Store project.

  2. Navigate to the project directory using your command line (CMD or terminal). For example:

    cd "C:\Users\YourUsername\redis-clone"

    Replace the path with your actual file directory if different.

  3. Run the following commands in separate terminals to start the servers and connect clients:

    # Terminal 1 - Start the master server
    node index.js --master --port=6379
    
    # Terminal 2 - Start the slave server
    node index.js --slave --port=6380 --masterHost=127.0.0.1 --masterPort=6379
    
    # Terminal 3 - Connect a client to the master server
    node client.js --port=6379
    
    # Terminal 4 - Connect a client to the slave server
    node client.js --port=6380

🧩 Usage Overview

This project supports running a Redis-like in-memory data store in Master-Slave Replication mode. Below are the available command-line options and their functions:

--master

Starts the master server. This is the primary node responsible for handling all write operations and broadcasting changes to connected slave nodes.

--slave

Starts a slave server. Upon launch, it will connect to the master server, fetch the current dataset, and begin listening for live updates (replication stream). The slave server operates in read-only mode.

client.js --port=6379

Launches a client connected to the master server at port 6379. Use this client to issue read and write commands. Changes here will be replicated to all connected slave nodes.

client.js --port=6380

Launches a client connected to the slave server at port 6380. Use this client to issue read-only commands. Write operations are not permitted on the slave to maintain data consistency.

💡 Note

  • Replication is real-time and handles both initial data sync and ongoing updates through persistence: AppendOnly File (AOF) and Snapshots.
  • Include error handling and automatic reconnection logic
  • Multiple slave servers can connect to the same master.
  1. Use commands in the client terminal to interact with the data store.
    (Refer to the Commands section for supported commands.)

Table of Contents

  1. 🔑 Core Key-Value Store

    • SET <key> <value>: Sets the value of the key.
    • GET <key>: Gets the value of the key.
    • DEL <key>: Deletes the specified key.
    • <command> <key> EX <seconds>: Sets an expiration time for the key in seconds.
    • TTL <key>: Retrieves the time to live for the key.
    • EXISTS <key>: Checks if the key exists. Returns 1 if the key exists, otherwise returns 0.
  2. 📦 Comprehensive Data Types

    1. String Commands

      • INCR <key>: Increments the value of the key by 1.
      • APPEND <key> <value>: Appends a value to an existing string.
      • STRLEN <key>: Retrieves the length of the value of a string.
      • GETRANGE <key> <start> <end>: Gets a substring of the string value of the key.
      • SETRANGE <key> <offset> <value>: Sets a substring of the string value of the key, starting at the given offset.
      • DECR <key>: Decrements the value of the key by 1.
      • INCRBY <key> <increment>: Increments the value of the key by the specified increment.
      • DECRBY <key> <decrement>: Decrements the value of the key by the specified decrement.
    2. JSON Commands

      • JSON.SET <key> <path> <json>: Sets a JSON value for the key at a specified path.
      • JSON.GET <key> <path>: Retrieves the value at a specified path in the JSON.
      • JSON.DEL <key> <path>: Deletes a value at a given path in the JSON object.
      • JSON.ARRAPPEND <key> <path> <value>: Appends an element to an array within the JSON.
    3. List Commands

      • LPUSH <key> <value>: Inserts an element at the head of the list stored at key.
      • RPUSH <key> <value>: Inserts an element at the tail of the list stored at key.
      • LRANGE <key> <start> <end>: Gets a range of elements from the list stored at key.
      • LPOP <key>: Removes and returns the first element of the list stored at key.
      • RPOP <key>: Removes and returns the last element of the list stored at key.
      • LSET <key> <index> <value>: Sets the value of an element in the list at the specified index.
      • LINDEX <key> <index>: Gets the element at the specified index in the list stored at key.
    4. Set Commands

      • SADD <key> <member>: Adds a member to the set.
      • SREM <key> <member>: Removes a member from the set.
      • SISMEMBER <key> <member>: Checks if a member exists in the set.
      • SMEMBERS <key>: Retrieves all members of the set.
      • SINTER <key1> <key2>: Returns the intersection of multiple sets.
      • SUNION <key1> <key2>: Returns the union of multiple sets.
      • SDIFF <key1> <key2>: Returns the difference between multiple sets.
    5. Hash Commands

      • HSET <key> <field> <value>: Sets the value of a field in a hash.
      • HGET <key> <field>: Retrieves the value of a field in a hash.
      • HMSET <key> <field1> <value1> <field2> <value2> ...: Sets multiple fields in a hash.
      • HGETALL <key>: Retrieves all fields and values in a hash.
      • HDEL <key> <field>: Removes a field from a hash.
      • HEXISTS <key> <field>: Checks if a field exists in a hash.
    6. Sorted Set Commands

      • ZADD <key> <score> <member>: Adds a member with a score to a sorted set.
      • ZRANGE <key> <start> <stop>: Retrieves members in a sorted set by rank.
      • ZRANK <key> <member>: Returns the rank of a member in a sorted set.
      • ZREM <key> <member>: Removes a member from a sorted set.
      • ZRANGEBYSCORE <key> <min> <max>: Retrieves members in a sorted set by score.
    7. Stream Commands

      • XADD <stream> <field> <value>: Appends a message to a stream.
      • XREAD <streams> <count>: Reads messages from one or more streams.
      • XRANGE <stream> <start> <end>: Retrieves a range of messages from the stream.
      • XLEN <stream>: Returns the length of the stream.
      • XGROUP CREATE <stream> <group> <id>: Creates a consumer group for a stream.
      • XREADGROUP <group> <consumer> <streams> <count>: Reads messages from a stream as part of a consumer group.
      • XACK <stream> <group> <id>: Acknowledges the message as processed in a consumer group.
    8. Geospatial Commands

      • GEOADD <key> <longitude> <latitude> <member>: Adds a geospatial member to a geospatial index.
      • GEOSEARCH <key> <longitude> <latitude> <radius> <unit>: Searches for geospatial members within a specified radius.
      • GEODIST <key> <member1> <member2> <unit>: Returns the distance between two geospatial members in the specified unit.
    9. Bitmap Commands

      • SETBIT <key> <offset> <value>: Sets or clears the bit at the specified offset in a bitmap.
      • GETBIT <key> <offset>: Returns the value of the bit at the specified offset in a bitmap.
      • BITCOUNT <key>: Returns the number of set bits (1s) in a bitmap.
      • BITOP <operation> <destkey> <key1> [key2 ...]: Performs bitwise operations (AND, OR, XOR, NOT) between multiple keys and stores the result in a destination key.
    10. Bitfield Commands

      • BITFIELD <key> GET <type> <offset>: Returns the value of a specific field in the bitfield at the given offset.
      • BITFIELD <key> SET <type> <offset> <value>: Sets a specific field in the bitfield at the given offset to the specified value.
      • BITFIELD <key> INCRBY <type> <offset> <increment>: Increments a specific field in the bitfield by the given value.
    11. HyperLogLog Commands

      • PFADD <key> <element1> <element2> ...: Adds elements to a HyperLogLog.
      • PFCOUNT <key>: Returns the approximate cardinality (number of unique elements) of the HyperLogLog.
      • PFMERGE <destkey> <sourcekey1> <sourcekey2> ...: Merges multiple HyperLogLogs into one.
    12. Time Series Commands

    • TS.CREATE <key> <options>: Creates a time series.
    • TS.ADD <key> <timestamp> <value>: Adds a value to a time series at a specific timestamp.
    • TS.RANGE <key> <start> <end>: Retrieves a range of values from a time series.
    • TS.GET <key>: Retrieves the latest value from a time series.
  3. 🔄 Transaction Commands

    • MULTI: Starts a transaction block.
    • EXEC: Executes all commands in a transaction.
    • DISCARD: Discards all commands in a transaction.
  4. 📡 PUB/SUB Commands

    • PUBLISH <channel> <message>: Publishes a message to a channel.
    • SUBSCRIBE <channel>: Subscribes to a channel.
    • UNSUBSCRIBE <channel>: Unsubscribes from a channel.
  5. 🧠 Test for Vector Database

    • VSET <key> <vector>: Sets a vector for the specified key.
    • VSEARCH <key> <query_vector> <num_results>: Searches for the nearest vectors to the provided query vector.
    • VADD <key> <vector>: Adds a vector to an existing key.
    • VSUB <key> <vector>: Subtracts a vector from an existing key.
    • VDOT <key1> <key2>: Computes the dot product of two vectors associated with the given keys.
  6. 📄 Test for Document Database

    • DOC.INDEX.CREATE <index> <field1> <field2> ...: Creates a document index with specified fields.
    • DOC.SET <key> <document>: Stores a JSON document at the specified key.
    • DOC.GET <key>: Retrieves the JSON document stored at the key.
    • DOC.UPDATE <key> <path> <value>: Updates a value at a specified path in the JSON document.
    • DOC.FIND <index> <query>: Finds documents matching the specified query from the index.
    • DOC.AGG <index> <pipeline>: Performs aggregation operations on documents in the index.

Commands

🔑 Core Key-Value Store

> SET mykey Hello
Server: OK
> GET mykey
Server: "Hello"
> DEL mykey
Server: (integer) 1
> EXISTS mykey
Server: (integer) 0

📦 Comprehensive Data Types

1. String Commands

> INCR mycounter
Server: (integer) 1
> APPEND mykey World
Server: (integer) 5
> STRLEN mykey
Server: (integer) 5
> GETRANGE mykey 0 4
Server: "World"
> SETRANGE mykey 5 There
Server: (integer) 10
> GET mykey
Server: "WorldThere"
> DECR mycounter
Server: (integer) 0
> INCRBY mycounter 5
Server: (integer) 5
> DECRBY mycounter 3
Server: (integer) 2

2. JSON Commands

> JSON.SET myjson .name Reyden
Server: OK
> JSON.GET myjson
Server: { "name": "Reyden" }
> JSON.DEL myjson .name
Server: (integer) 1
> JSON.GET myjson
Server: "(nil)"

3. List Commands

> LPUSH mylist 10
Server: (integer) 1
> RPUSH mylist 20
Server: (integer) 2
>  LINDEX mylist 0
Server: 10
>  LINDEX mylist 1
Server: 20
> LRANGE mylist 0 -1
1) "10"
2) "20"
> LPOP mylist
Server: "10"
> RPOP mylist
Server: "20"
> LRANGE mylist 0 -1
Server: "(nil)"
> LSET mylist 0 30
Server: -ERR execution error 'LSET': ERR index out of range

4. Set Commands

> SADD myset1 1
Server: (integer) 1
> SADD myset1 2
Server: (integer) 1
> SADD myset1 3
Server: (integer) 1
> SADD myset2 1
Server: (integer) 1
> SADD myset2 4
Server: (integer) 1
> SADD myset2 5
Server: (integer) 1
> SMEMBERS myset1
1) "1"
2) "2"
3) "3"
> SMEMBERS myset2
1) "1"
2) "4"
3) "5"
> SREM myset1 2
Server: (integer) 1
> SMEMBERS myset1
1) "1"
2) "3"
> SISMEMBER myset1 1
Server: (integer) 1
> SISMEMBER myset1 4
Server: (integer) 0
> SINTER myset1 myset2
1) "1"
> SUNION myset1 myset2
1) "1"
2) "3"
3) "4"
4) "5"
> SDIFF myset1 myset2
1) "3"
> SDIFF myset2 myset1
1) "4"
2) "5"

5. Hash Commands

> HSET myhash field1 value1
Server: (integer) 1
> HGET myhash field1
Server: "value1"
> HMSET myhash field2 value2 field3 value3
Server: (integer) 1
> HGETALL myhash
1) "field1"
2) "value1"
3) "field2"
4) "value2"
5) "field3"
6) "value3"
> HDEL myhash field2
Server: (integer) 1
> HEXISTS myhash field2
Server: (integer) 0
> HGETALL myhash
1) "field1"
2) "value1"
3) "field3"
4) "value3"

6. Sorted Set Commands

> ZADD myzset 1 "one"
Server: (integer) 1
> ZADD myzset 2 "two"
Server: (integer) 1
> ZADD myzset 3 "three"
Server: (integer) 1
> ZRANGE myzset 0 -1
1) "one"
2) "two"
3) "three"
> ZRANK myzset "one"
Server: (integer) 0
> ZRANK myzset "two"
Server: (integer) 1
> ZRANK myzset "three"
Server: (integer) 2
> ZREM myzset "two"
Server: (integer) 1
> ZRANGE myzset 0 -1
1) "one"
2) "three"
> ZRANGEBYSCORE myzset 1 2
1) "one"
2) "two"
> ZRANGEBYSCORE myzset 2 3
1) "two"
2) "three"
> ZRANGEBYSCORE myzset 1 3
1) "one"
2) "two"
3) "three"

7. Stream Commands

> XADD mystream * sensor-id 1234 temperature 19.8 humidity 43.5
Server: "1744389097971-588"
> XADD mystream * sensor-id 5678 temperature 22.1 humidity 41.2
Server: "1744389097978-979"
> XGROUP CREATE mystream mygroup 0
Server: OK
> XADD mystream * sensor-id 9012 temperature 25.0 humidity 40.0
Server: "1744389097982-829"
> XREADGROUP GROUP mygroup consumer1 COUNT 2 STREAMS mystream >
Server:
1) "mystream"
2)
  *
  1)
    *
    1) "1745447113156-582"
    2)
      *
      1) "sensor-id"
      2) "1234"
      3) "temperature"
      4) "19.8"
      5) "humidity"
      6) "43.5"
  2)
    *
    1) "1745447117295-399"
    2)
      *
      1) "sensor-id"
      2) "5678"
      3) "temperature"
      4) "22.1"
      5) "humidity"
      6) "41.2"
> XACK mystream mygroup <latest-data>
Server: (integer) 1
> XLEN mystream
Server: (integer) 3
> XGROUP CREATE mystream mygroup $
Server: -BUSYGROUP
> XREADGROUP GROUP mygroup consumer1 COUNT 2 STREAMS mystream >
Server:
1) "mystream"
2)
  *
  1)
    *
    1) "1745447549063-553"
    2)
      *
      1) "sensor-id"
      2) "9012"
      3) "temperature"
      4) "25.0"
      5) "humidity"
      6) "40.0"
> XRANGE mystream - +
Server:
1)
  *
  1) "1745447549026-329"
  2)
    *
    1) "sensor-id"
    2) "1234"
    3) "temperature"
    4) "19.8"
    5) "humidity"
    6) "43.5"
2)
  *
  1) "1745447549031-488"
  2)
    *
    1) "sensor-id"
    2) "5678"
    3) "temperature"
    4) "22.1"
    5) "humidity"
    6) "41.2"
3)
  *
  1) "1745447549063-553"
  2)
    *
    1) "sensor-id"
    2) "9012"
    3) "temperature"
    4) "25.0"
    5) "humidity"
    6) "40.0"
> XREAD COUNT 2 STREAMS mystream 0
Server:
1) "mystream"
2)
  *
  1)
    *
    1) "1745447549026-329"
    2)
      *
      1) "sensor-id"
      2) "1234"
      3) "temperature"
      4) "19.8"
      5) "humidity"
      6) "43.5"
  2)
    *
    1) "1745447549031-488"
    2)
      *
      1) "sensor-id"
      2) "5678"
      3) "temperature"
      4) "22.1"
      5) "humidity"
      6) "41.2"

8. Geospatial Commands

> GEOADD mygeoset 13.361389 38.115556 Palermo
Server: (integer) 1
> GEOSEARCH mygeoset FROMLONLAT 13.361389 38.115556 BYRADIUS 200 km
1)
  *
  1) "Palermo"
> GEODIST mygeoset Palermo Palermo km
Server: (integer) 0
> GEOADD mygeoset 15.087269 37.502669 Catania
Server: (integer) 1
> GEOSEARCH mygeoset FROMLONLAT 13.361389 38.115556 BYRADIUS 200 km
1)
  *
  1) "Palermo"
2)
  *
  1) "Catania"
> GEODIST mygeoset Palermo Catania km
Server: "166.2274"

9. Bitmap Commands

> SETBIT mybitmap 7 1
Server: (integer) 0
> GETBIT mybitmap 7
Server: (integer) 1
> BITCOUNT mybitmap
Server: (integer) 1
> BITOP AND mybitmap mybitmap mybitmap
Server: (integer) 1

127.0.0.1:6380> SETBIT a 2 1
(integer) 0
127.0.0.1:6380> SETBIT a 3 1
(integer) 0
127.0.0.1:6380> SETBIT b 1 1
(integer) 0
127.0.0.1:6380> SETBIT b 3 1
(integer) 0
127.0.0.1:6380> GETBIT a 2
(integer) 1
127.0.0.1:6380> GETBIT a 0
(integer) 0
127.0.0.1:6380> BITOP AND result a b
(integer) 1
127.0.0.1:6380> BITOP OR result a b
(integer) 1
127.0.0.1:6380> BITOP XOR result a b
(integer) 1
127.0.0.1:6380> BITOP NOT result a
(integer) 1
127.0.0.1:6380> BITCOUNT a
(integer) 2
127.0.0.1:6380> BITCOUNT b
(integer) 2

10. Bitfield Commands

# Signed Bit
127.0.0.1:6380> BITFIELD mybitfield SET i4 0 -5
1) (integer) 0
127.0.0.1:6380> BITFIELD mybitfield GET i4 0
1) (integer) -5
127.0.0.1:6380> BITFIELD mybitfield INCRBY i4 0 3
1) (integer) -2

# Unsigned Bit
127.0.0.1:6380> BITFIELD mybitfield SET u4 9 9
1) (integer) 0
127.0.0.1:6380> BITFIELD mybitfield GET u4 9
1) (integer) 9
127.0.0.1:6380> BITFIELD mybitfield INCRBY u4 9 5
1) (integer) 14

# Out of range
127.0.0.1:6380> BITFIELD mybitfield SET i4 30 9
1) (integer) 0
127.0.0.1:6380> BITFIELD mybitfield GET i4 30
1) (integer) -7

# Overwritten Range
127.0.0.1:6380> BITFIELD mybitfield SET i4 29 2
1) (integer) 4
127.0.0.1:6380> BITFIELD mybitfield GET i4 30
1) (integer) 5

11. HyperLogLog Commands

> PFADD myhll1 "apple"
Server: (integer) 1
> PFADD myhll1 "banana"
Server: (integer) 1
> PFADD myhll1 "cherry"
Server: (integer) 1
> PFCOUNT myhll1
Server: (integer) 3
> PFADD myhll1 "apple"  # Adding an existing element
Server: (integer) 0
> PFCOUNT myhll1
Server: (integer) 3
> PFADD myhll2 "date"
Server: (integer) 1
> PFADD myhll2 "elderberry"
Server: (integer) 1
> PFCOUNT myhll2
Server: (integer) 2
> PFMERGE myhll_combined myhll1 myhll2
Server: OK
> PFCOUNT myhll_combined
Server: (integer) 5
> PFADD myhll_combined "fig"
Server: (integer) 1
> PFCOUNT myhll_combined
Server: (integer) 6

12. Time Series Commands

> TS.CREATE mytimeseries
Server: OK
> TS.ADD mytimeseries 1625122800 10
Server: OK
> TS.RANGE mytimeseries 1625122800 1625222800
1)
  *
  1) 1625122800
  2) 10
> TS.GET mytimeseries
1) (integer) 1625122800
2) "10"

> TS.CREATE mytimeseries2 RETENTION 3600000 LABELS source sensor
Server: OK
> TS.ADD mytimeseries2 1625122800 10
Server: OK
> TS.ADD mytimeseries2 1625130000 20
Server: OK
> TS.RANGE mytimeseries2 1625122800 1625222800
 1)
  *
  1) 1625122800
  2) 10
2)
  *
  1) 1625130000
  2) 20
> TS.GET mytimeseries2
1) (integer) 1625130000
2) "20"

🔄 Transaction Commands

> MULTI
OK
> SET mykey value1
QUEUED
> GET mykey
QUEUED
> INCR counter
QUEUED
> EXEC
1) "OK"
2) "value1"
3) (integer) 1

> MULTI
OK
> SET mykey value1
QUEUED
> GET mykey
QUEUED
> INCR counter
QUEUED
> DISCARD
OK

📡 PUB/SUB Commands

Subscribe <channel-name>
1) subscribe
2) <channel-name>
3) <number of client subscribed>

Publish <channel-name> <chat>
1) message
2) <channel-name>
3) <chat>
<number of client subscribed>

🧠 Test for Vector Database

> VSET mykey "That is a very happy person"
Server: OK
> VSET mykey2 "Today is a sunny day"
Server: OK
> VSEARCH "That is a happy person"
Server: "Key: "mykey" (score: 0.9655)
Key: "mykey2" (score: 0.9659)"

> VSET book1 "A thrilling mystery with unexpected twists"
Server: OK
> VSET book2 "A story about love and life in a small town"
Server: OK
> VSEARCH "A small town mystery"
Server: "Key: "mykey" (score: 0.9771)
Key: "book1" (score: 0.9849)
Key: "mykey2" (score: 0.9853)
Key: "book2" (score: 0.9873)"

> VSET alpha "apple banana cherry"
Server: OK
> VSET beta "banana cherry durian"
Server: OK
> VADD alpha beta
Server: "(-0.15, -0.11, -0.03, -0.03, -0.09, 0.01, -0.03, 0.02, -0.08, 0.05, 0.09, 0.03, 0.04, 0.10, -0.12, 0.00, -0.01, 0.02, 0.04, 0.05, -0.02, -0.04, -0.04, 0.02, -0.00, -0.01, 0.11, -0.06, 0.07, -0.12, 0.02, -0.03, -0.02, 0.07, 0.00, -0.09, 0.10, 0.13, 0.04, 0.10, -0.01, 0.00, -0.03, -0.04, -0.13, 0.06, 0.06, -0.07, -0.03, -0.02, 0.00, -0.05, -0.13, -0.01, 0.17, -0.05, 0.01, 0.06, 0.05, 0.05, 0.00, -0.02, 0.01, 0.08, 0.08, 0.02, 0.19, -0.02, 0.09, 0.12, -0.06, -0.04, 0.02, 0.05, -0.04, -0.15, -0.13, -0.04, -0.01, -0.05, -0.04, 0.13, -0.07, 0.06, -0.08, 0.09, -0.08, 0.05, 0.03, -0.09, -0.14, -0.05, 0.05, -0.01, -0.08, -0.07, 0.04, 0.04, 0.14, -0.01, 0.06, 0.08, 0.01, 0.10, -0.05, 0.01, -0.05, -0.08, 0.00, 0.11, 0.07, 0.06, 0.09, -0.07, -0.06, -0.03, -0.13, -0.06, -0.08, 0.03, 0.03, 0.11, 0.06, -0.05, 0.01, 0.07, -0.07, 0.02, 0.11, 0.09, -0.02, -0.06, -0.00, 0.01, 0.13, 0.03, 0.03, 0.11, 0.15, -0.00, 0.03, 0.12, -0.03, -0.01, -0.11, 0.02, -0.01, 0.02, -0.01, -0.06, 0.11, 0.16, -0.15, 0.04, 0.11, 0.07, -0.11, -0.06, 0.12, -0.09, 0.00, -0.11, -0.08, -0.04, -0.04, -0.09, -0.04, -0.01, -0.09, 0.00, 0.02, 0.03, 0.01, -0.15, 0.09, 0.12, -0.04, 0.11, 0.03, -0.10, 0.12, -0.24, 0.00, -0.00, -0.06, 0.08, -0.03, -0.03, -0.05, -0.02, 0.01, -0.05, -0.03, 0.05, -0.12, -0.02, 0.13, -0.06, 0.09, 0.02, -0.02, -0.00, 0.20, -0.07, -0.03, -0.14, 0.14, -0.05, 0.02, -0.06, 0.16, -0.01, 0.04, -0.11, 0.07, 0.04, 0.01, 0.01, 0.07, 0.02, 0.07, -0.10, 0.07, -0.08, -0.06, 0.07, 0.05, -0.11, -0.02, 0.02, 0.10, 0.01, 0.11, -0.07, -0.08, -0.04, 0.02, 0.07, -0.03, -0.00, 0.07, 0.04, -0.10, 0.13, -0.02, -0.00, -0.05, -0.05, 0.03, -0.04, -0.01, -0.05, -0.07, -0.01, 0.14, -0.03, -0.09, -0.06, -0.09, -0.03, -0.08, -0.07, 0.01, -0.07, 0.09, -0.07, 0.00, -0.00, -0.03, -0.01, 0.09, 0.10, -0.02, -0.01, -0.06, 0.08, -0.07, 0.00, -0.06, 0.10, -0.03, 0.05, -0.11, -0.00, -0.04, 0.01, 0.05, 0.15, -0.06, -0.00, -0.06, -0.00, 0.07, 0.05, 0.07, -0.01, -0.04, -0.05, 0.14, 0.07, -0.13, -0.00, 0.01, -0.02, -0.11, 0.14, 0.10, -0.06, -0.06, 0.12, -0.01, -0.02, 0.03, 0.09, 0.05, -0.07, -0.02, 0.14, -0.00, -0.02, -0.00, -0.01, -0.11, 0.01, -0.03, 0.13, -0.00, 0.06, 0.00, 0.02, -0.02, -0.13, -0.06, 0.03, 0.05, -0.09, -0.09, 0.04, 0.03, -0.05, 0.05, 0.01, 0.00, -0.06, -0.12, 0.00, -0.04, -0.01, -0.06, -0.09, 0.08, 0.05, -0.02, -0.08, -0.07, -0.05, -0.04, 0.03, 0.04, 0.05, 0.13, 0.04, -0.06, 0.24, -0.07, 0.06, -0.10, -0.00, 0.03, 0.08, 0.06, 0.05, -0.06, 0.04, 0.02, 0.05, 0.04, -0.05, 0.09, 0.07, -0.06, -0.11, -0.01, 0.04, 0.03, -0.13, -0.04, -0.10, -0.04, -0.09, 0.07, -0.00, 0.01, -0.10, 0.06, 0.05, 0.03, 0.07, 0.06, 0.06, 0.05, -0.02, 0.01, 0.15, 0.03, -0.01, -0.04, 0.03, -0.02, -0.02, 0.05, 0.08, -0.00, -0.03, 0.12, 0.09, -0.03, -0.11, 0.05, -0.19, 0.10, 0.00, 0.03, 0.05, 0.03, -0.02, 0.15, -0.17, 0.04, 0.01, 0.03, -0.02, -0.14, 0.17, -0.07, -0.12, -0.02, 0.16, 0.11, 0.03, 0.04, -0.08, -0.09, 0.02, -0.04, -0.00, 0.03, 0.04, -0.08, 0.08, 0.17, -0.13, 0.12, 0.06, 0.07, -0.01, 0.01, -0.19, 0.07, 0.07, 0.04, 0.08, -0.17, -0.03, 0.00, -0.04, 0.07, -0.08, 0.09, -0.11, 0.01, -0.04, -0.07, 0.02, -0.00, -0.03, 0.03, -0.11, -0.11, 0.04, -0.02, 0.01, 0.07, 0.01, -0.03, -0.07, -0.06, -0.01, -0.03, -0.02, 0.05, 0.02, -0.12, -0.01, 0.07, 0.03, -0.06, -0.10, -0.00, 0.11, -0.04, -0.05, 0.06, -0.06, -0.02, 0.08, 0.00, 0.11, -0.09, -0.02, 0.05, 0.11, -0.06, 0.00, 0.06, -0.01, -0.12, 0.05, -0.04, 0.03, 0.00, -0.05, 0.05, 0.00, 0.10, -0.07, -0.03, -0.05, -0.04, -0.12, -0.04, -0.07, 0.03, -0.06, 0.04, 0.07, -0.11, 0.06, -0.07, 0.03, -0.05, 0.01, 0.13, 0.04, -0.04, -0.02, -0.06, -0.04, -0.11, -0.03, 0.13, 0.09, -0.03, -0.02, -0.13, -0.00, 0.05, 0.00, -0.07, 0.06, -0.01, 0.00, -0.01, 0.08, 0.05, -0.04, 0.01, -0.01, 0.00, -0.12, 0.08, -0.02, 0.03, 0.00, 0.02, -0.10, 0.08, 0.02, 0.09, 0.04, -0.04, 0.05, -0.01, 0.01, -0.03, -0.12, 0.12, 0.00, 0.00, 0.07, 0.01, -0.13, -0.04, -0.07, -0.13, -0.05, 0.07, 0.04, 0.06, -0.03, -0.03, -0.18, -0.00, -0.00, 0.02, 0.01, 0.08, -0.02, 0.10, -0.09, -0.11, 0.01, 0.06, -0.11, -0.09, 0.02, 0.09, 0.11, -0.09, -0.05, 0.03, -0.01, 0.22, 0.05, 0.04, 0.03, 0.01, -0.05, 0.03, 0.05, 0.13, -0.14, -0.05, 0.11, -0.00, -0.01, -0.10, -0.04, -0.02, 0.12, 0.07, 0.00, -0.05, -0.00, 0.02, -0.10, 0.19, 0.02, -0.19, -0.06, 0.04, -0.11, 0.02, 0.02, -0.03, -0.10, -0.01, 0.00, -0.02, -0.02, 0.09, -0.04, -0.03, 0.08, -0.05, -0.01, 0.05, 0.03, 0.12, 0.01, -0.03, -0.09, 0.05, 0.03, -0.06, 0.06, -0.08, -0.06, -0.01, 0.05, -0.11, -0.14, 0.04, 0.07, -0.17, -0.02, -0.02, -0.03, 0.00, -0.08, -0.03, 0.01, 0.00, -0.02, 0.01, -0.04, 0.02, 0.03, -0.12, 0.04, -0.11, -0.02, 0.12, 0.16, -0.14, 0.05, -0.01, 0.05, 0.05, 0.02, -0.07, 0.12, -0.07, 0.11, -0.06, 0.05, -0.17, 0.01, -0.07, -0.00, -0.08, 0.04, -0.06, 0.02, 0.05, 0.06, 0.06, 0.04, 0.03, -0.12, -0.04, -0.01, -0.14, -0.01, -0.00, -0.02, 0.12, -0.04, -0.04, 0.00, -0.05, -0.01, -0.09, 0.02, 0.04, 0.05, 0.00, -0.03, -0.02, -0.13, -0.06, -0.01, 0.19, -0.02, -0.01, 0.01, 0.00, -0.01, -0.05, -0.01, -0.02, -0.04, 0.04, 0.09, -0.01, 0.04, 0.07, -0.13)"
> VSUB alpha beta
Server: "(-0.00, -0.00, -0.00, -0.00, 0.00, -0.00, -0.00, -0.00, -0.00, 0.00, -0.00, -0.00, -0.00, 0.00, -0.00, -0.00, 0.00, -0.00, -0.00, -0.00, -0.00, -0.00, 0.00, -0.00, -0.00, -0.00, 0.00, 0.00, 0.00, 0.01, -0.00, -0.00, 0.00, 0.00, -0.00, 0.00, 0.00, 0.00, 0.00, -0.00, -0.00, 0.00, -0.00, -0.00, -0.00, 0.00, -0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, -0.00, -0.00, 0.00, 0.00, 0.00, -0.00, 0.00, -0.00, 0.00, -0.00, -0.00, -0.00, 0.00, 0.00, -0.00, 0.00, 0.00, -0.00, 0.00, 0.00, 0.00, 0.00, -0.00, 0.00, -0.00, 0.00, 0.00, -0.00, -0.00, -0.00, 0.00, -0.00, -0.00, -0.00, -0.00, 0.00, -0.00, 0.00, 0.00, -0.00, 0.00, -0.00, -0.00, -0.00, -0.00, -0.00, 0.00, -0.00, -0.00, 0.00, 0.00, -0.00, -0.01, 0.00, 0.00, 0.00, 0.00, -0.00, -0.00, 0.00, -0.00, -0.00, 0.00, 0.00, -0.00, 0.00, -0.00, 0.00, -0.00, -0.00, -0.00, 0.00, 0.00, 0.00, 0.00, 0.00, -0.00, -0.00, -0.00, 0.00, 0.00, 0.00, 0.00, -0.00, -0.00, -0.00, -0.00, 0.00, -0.00, -0.00, -0.00, -0.00, -0.00, -0.00, 0.00, 0.00, 0.00, 0.00, -0.00, -0.00, 0.00, 0.00, -0.00, -0.00, -0.00, -0.00, 0.00, 0.00, 0.00, -0.00, 0.00, -0.00, -0.00, -0.00, -0.00, 0.00, 0.00, 0.00, 0.00, -0.00, -0.00, -0.00, -0.00, 0.00, 0.00, 0.00, -0.00, 0.01, -0.00, 0.00, 0.00, -0.00, 0.00, -0.00, 0.00, -0.00, -0.00, 0.00, -0.00, -0.00, -0.00, 0.00, 0.00, 0.00, 0.00, 0.00, -0.00, 0.00, 0.00, 0.00, 0.00, -0.00, 0.00, -0.00, -0.00, 0.00, 0.00, 0.00, 0.00, 0.00, -0.00, -0.00, -0.00, 0.00, -0.00, 0.00, 0.00, -0.00, 0.00, -0.00, -0.00, -0.00, 0.00, -0.00, -0.00, 0.00, -0.00, -0.00, 0.00, -0.00, -0.00, -0.00, -0.00, 0.00, 0.00, -0.00, -0.00, -0.00, 0.00, 0.00, 0.00, 0.00, -0.00, -0.00, -0.00, -0.00, 0.00, -0.00, -0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, -0.00, -0.00, 0.00, -0.00, -0.00, 0.00, -0.00, -0.00, -0.00, -0.00, 0.00, -0.00, 0.00, -0.00, 0.00, 0.00, 0.00, -0.00, -0.00, 0.00, 0.00, 0.00, -0.00, -0.00, -0.00, -0.00, 0.00, 0.00, 0.00, -0.00, 0.00, 0.00, -0.00, 0.00, 0.00, -0.00, -0.00, 0.00, -0.00, -0.00, 0.00, 0.00, -0.00, 0.00, 0.00, 0.00, -0.00, 0.00, 0.00, 0.00, -0.00, -0.00, 0.00, 0.00, -0.00, -0.00, 0.01, 0.00, 0.00, -0.00, 0.00, -0.00, -0.00, -0.00, 0.00, 0.00, -0.00, -0.00, 0.00, -0.00, -0.00, 0.00, 0.00, 0.00, 0.00, -0.00, 0.00, -0.00, -0.00, 0.00, -0.00, -0.00, -0.00, -0.00, 0.00, 0.00, 0.00, -0.01, 0.00, -0.00, 0.00, -0.00, -0.00, -0.00, 0.00, 0.00, -0.00, -0.00, 0.00, 0.00, 0.00, -0.00, 0.00, 0.00, -0.00, -0.00, 0.00, -0.00, -0.00, 0.00, 0.00, 0.00, -0.00, -0.01, 0.00, -0.00, -0.00, -0.00, 0.00, -0.00, 0.00, 0.00, 0.00, 0.00, -0.00, -0.00, -0.00, -0.00, 0.00, 0.00, -0.00, 0.00, -0.00, -0.00, -0.00, -0.00, 0.00, -0.00, -0.00, 0.00, 0.00, -0.00, 0.00, -0.01, 0.00, -0.00, 0.00, -0.00, -0.00, 0.00, -0.00, 0.00, 0.00, 0.00, -0.00, -0.00, 0.00, 0.00, 0.00, -0.00, 0.00, -0.00, -0.00, -0.00, -0.00, -0.00, -0.00, 0.00, 0.00, 0.00, 0.00, -0.00, -0.00, -0.00, 0.00, 0.00, -0.00, 0.00, 0.00, 0.00, 0.00, -0.00, -0.00, 0.00, -0.00, 0.00, 0.00, -0.00, -0.00, -0.00, -0.00, 0.00, 0.00, -0.00, 0.00, 0.00, -0.00, 0.00, 0.00, -0.00, -0.00, -0.00, 0.00, 0.00, -0.00, -0.00, -0.00, 0.00, 0.00, 0.00, -0.00, 0.00, 0.00, -0.00, -0.00, 0.00, -0.00, -0.00, -0.00, 0.00, -0.00, -0.00, 0.00, 0.00, 0.00, 0.00, -0.00, 0.00, 0.00, -0.00, 0.00, -0.00, 0.00, -0.00, 0.00, -0.00, 0.00, 0.00, -0.00, -0.00, -0.00, -0.00, -0.00, 0.00, -0.00, 0.00, -0.00, -0.00, 0.00, 0.00, 0.00, -0.00, -0.00, -0.00, 0.00, 0.00, 0.00, 0.00, -0.00, -0.00, 0.00, -0.00, 0.00, -0.00, 0.00, -0.00, -0.00, -0.00, -0.00, -0.01, 0.00, 0.00, -0.00, 0.01, 0.00, -0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, -0.00, -0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, -0.00, 0.00, -0.00, -0.00, -0.00, 0.00, 0.00, -0.00, 0.00, -0.00, -0.00, 0.00, -0.00, 0.00, -0.00, 0.00, -0.00, -0.00, 0.00, 0.00, 0.00, 0.00, -0.00, 0.00, -0.00, -0.00, -0.00, 0.00, -0.00, -0.00, -0.00, 0.00, -0.00, 0.00, -0.00, -0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, -0.00, -0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, -0.00, -0.00, -0.00, -0.00, -0.00, 0.00, 0.00, -0.00, 0.00, -0.00, 0.00, 0.00, -0.00, 0.00, -0.00, -0.01, 0.00, -0.00, -0.00, 0.00, -0.00, 0.00, -0.00, 0.00, -0.00, -0.00, 0.00, 0.00, 0.00, -0.00, -0.00, -0.00, 0.00, -0.00, -0.00, 0.00, 0.00, 0.00, -0.00, 0.00, -0.00, -0.00, 0.00, 0.00, -0.00, -0.00, -0.00, -0.00, 0.00, -0.00, 0.00, -0.00, 0.00, -0.00, -0.00, -0.00, 0.00, 0.00, 0.00, 0.00, 0.00, -0.00, 0.00, 0.00, 0.00, -0.00, 0.00, -0.00, -0.00, 0.00, -0.00, 0.00, -0.00, -0.00, -0.00, 0.00, -0.00, -0.00, -0.00, -0.00, -0.00, -0.00, -0.00, 0.00, -0.00, -0.00, -0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, -0.00, -0.01, -0.00, -0.00, 0.00, -0.00, -0.00, 0.00, 0.00, -0.00, 0.00, 0.00, 0.00, -0.00, -0.00, 0.00, 0.01, -0.00, 0.00, 0.00, 0.00, 0.00, -0.00, 0.00, -0.00, -0.00, -0.00, -0.00, -0.00, -0.00, 0.00, -0.00, -0.00, -0.00, 0.00, -0.00, 0.00, 0.00, 0.00, -0.00, 0.00, -0.00, 0.00, -0.00, 0.00, -0.00, -0.00, 0.00, 0.00, -0.00, -0.00, 0.00, 0.00, 0.00, -0.00, -0.00, 0.00, 0.00, -0.00, -0.00, 0.00, -0.00, 0.00, 0.00, -0.00, 0.00, 0.00, -0.00, 0.00, 0.00, 0.00)"
> VDOT alpha beta
Server: "0.9984"

📄 Test for Document Database

> DOC.INDEX.CREATE users ON JSON PREFIX user: SCHEMA $.name TEXT $.age NUMERIC $.location GEO
Server: OK
> DOC.SET user:4 {"name":"Reyden", "age":22, "skills":["JS", "Redis"]}
Server: OK
> DOC.GET user:4
Server: {"name":"Reyden","age":22,"skills":["JS","Redis"]}
> DOC.GET user:4 PATH $.name
Server: "Reyden"
> DOC.UPDATE user:4 SET $.name "Reyden Cagata" INCR $.age 1 APPEND $.skills "Node.js"
Server: OK
> DOC.GET user:4
Server: {"name":"Reyden Cagata","age":23,"skills":["JS","Redis","Node.js"]}
> DOC.SET user:1 {"name":"Alice", "age":30, "score":85}
Server: OK
> DOC.SET user:2 {"name":"Bob", "age":25, "score":92}
Server: OK
> DOC.SET user:3 {"name":"Charlie", "age":35, "score":78}
Server: OK
> DOC.AGG users COUNT $.name
Server: 4
> DOC.AGG users SUM $.age
Server: 113
> DOC.AGG users AVG $.score
Server: 85.00
> DOC.FIND users "@name:Alice" WITHSCORES RETURN 2 $.name $.age
Server: [{"name":"Alice","age":30}]
> DOC.FIND users "@name:Bob" WITHSCORES RETURN 1 $.age
Server: [{"age":25}]
> DOC.FIND users "@name:Charlie" WITHSCORES RETURN 2 $.age $.score
Server: [{"age":35,"score":78}]

📄 Test for Key Expiration

1. String Commands

SET stringkey stringvalue EX 10
TTL stringkey
GET stringkey
EXISTS stringkey

SET stringkey stringvalue
EXPIRE stringkey 5
TTL stringkey
GET stringkey
EXISTS stringkey

INCR mycounter ex 10
TTL mycounter
GET mycounter
EXIST mycounter

2. JSON Commands

JSON.SET myjson .name Alice EX 10
TTL myjson
JSON.GET myjson
EXISTS myjson

3. List Commands

LPUSH listkey 10
RPUSH listkey 20
LRANGE listkey 0 -1
EXPIRE listkey 10
TTL listkey
LRANGE listkey 0 -1

LPUSH listkey item1
LPUSH listkey item2
LRANGE listkey 0 -1
EXPIRE listkey 5
TTL listkey
LRANGE mylist 0 -1

4. Set Commands

SADD setkey member1 EX 5
SMEMBERS setkey
TTL setkey
EXISTS setkey

SADD setkey member1
EXPIRE setkey 5
TTL setkey
EXISTS setkey

5. Hash Commands

HSET myhash field1 value1 EX 10
TTL myhash
HGET myhash field1

HMSET myhash field1 value1 field2 value2 EX 10
TTL myhash
HGET myhash field1

6. Sorted Set Commands

ZADD zset 1 "member1" EX 10
TTL zset
EXISTS zset

7. Stream Commands

XADD mystream * message "hello" EX 10
TTL mystream
EXISTS mystream

8. Geospatial Commands

GEOADD mygeo 13.361389 38.115556 "Palermo" EX 10
TTL mygeo
EXISTS mygeo

9. Bitmap Commands

SETBIT mybitmap 1 1 EX 10
TTL mybitmap
EXISTS mybitmap

10. Bitfield Commands

BITFIELD mybitfield set i8 #0 100 EX 10
TTL mybitfield
EXISTS mybitfield

11. HyperLogLog Commands

PFADD myhll element1 EX 10
TTL myhll
EXISTS myhll

12. Time Series Commands

TS.CREATE mytimeseries EX 10
TS.ADD mytimeseries 1625122800 10 EX 10
TTL mytimeseries
TS.GET mytimeseries

About

A Node.js implementation of a Redis‑like in‑memory data store with master–slave replication, persistence, and support for common Redis‑style commands.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published