Commit Graph

554 Commits

Author SHA1 Message Date
Kelvin Mwinuka
a19bfa8f73 Implemented rlocking/runlocking of rwmutex in Channel IsActive and NumSubs receiver functions. Implemented PUBSUB NUMPAT handler unit test 2024-03-20 12:36:03 +08:00
Kelvin Mwinuka
852f23b36e Removed context parameter and implemented locking of RWMutex in NumPat and NumSub receiver functions in PubSub module 2024-03-20 05:00:15 +08:00
Kelvin Mwinuka
f41e2f6ff3 Added RWMutexes in PubSub Subscribe, Unsubscribe, and Channels receiver functions. Implemented test for PUBSUB CHANNELS command handler 2024-03-20 04:58:03 +08:00
Kelvin Mwinuka
c7c38cfff2 Return array when PUBSUB CHANNELS command is called with a pattern 2024-03-20 00:31:55 +08:00
Kelvin Mwinuka
28f659033e Removed discord label from README.md. Updated SUBSCRIBE command handler to send psubscribe event to connection when subscribing to a pattern. 2024-03-20 00:18:38 +08:00
Kelvin Mwinuka
59a03aec2c Added test for PUBLISH command handler 2024-03-18 14:05:49 +08:00
Kelvin Mwinuka
dbfa398543 Implemented tests for SUBSCRIBE, PSUBSCRIBE, UNSUBSCRIBE, and PUNSUBSCRIBE command handlers 2024-03-17 02:41:49 +08:00
Kelvin Mwinuka
e685d5041b Updated test suites to set mock server only once in each suite instead of instantiating it in every test. 2024-03-15 03:44:42 +08:00
Kelvin Mwinuka
b49a0e24bc Created command test file in pubsub module 2024-03-14 23:55:14 +08:00
Kelvin Mwinuka
28dcfd2835 Created test file for acl module commands 2024-03-14 07:08:12 +08:00
Kelvin Mwinuka
f68a369f0a Implemented tests for all commands handlers in the generic module 2024-03-14 07:04:09 +08:00
Kelvin Mwinuka
6db02f90eb Re-implemented MSET, GET and MGET command handler tests 2024-03-14 01:43:01 +08:00
Kelvin Mwinuka
8fc68a9028 Implemented test for new SET command format 2024-03-14 01:41:36 +08:00
Kelvin Mwinuka
348bae3668 Merge pull request #11 from EchoVault/feature/eviction-policy
Introduce Key Eviction policies for Memory Footprint management
2024-03-13 02:20:02 +08:00
Kelvin Mwinuka
ed683ca803 Commend formatting 2024-03-12 23:20:25 +08:00
Kelvin Mwinuka
90ed2d44b4 Removed KEY and CERT environment variables for all cluster nodes in docker compose file.
broadcastRaftAddress function in memberlist package no longer requires a context to be passed to it.
Moved FilterExpiredKeys function to utils package as it's shared by aof engine, snapshot engine, and raft snapshot store.
2024-03-12 23:10:45 +08:00
Kelvin Mwinuka
52646d1564 Take expiry into account when creating snashot and AOF preamble. If the key is already expired when snapshot is taken, it will not be persisted. If the key is expired when loading a snapshot/preamble, it will not be restored. 2024-03-12 21:35:39 +08:00
Kelvin Mwinuka
f27a0dda79 Implemented eviction algorithm that samples a configurable number of keys with TTLs (default 20) at a configurable interval (default 100ms) and deletes the keys that are expired. 2024-03-12 02:12:55 +08:00
Kelvin Mwinuka
52b39d5b0f Re-enabled cluster nodes in docker-compose.yml.
Created flow to forward key deletion command from non-leader node to leader node.
Created flow for propagating key deletion accross the entire cluster to maintain consistency of the deleted keys.
2024-03-11 20:39:57 +08:00
Kelvin Mwinuka
c611dd60ee Created flow for deleting key consistently within cluster. 2024-03-11 05:22:38 +08:00
Kelvin Mwinuka
8000cef72d Added RWMutex to keysWithExpiry in order to improve thread safety 2024-03-11 02:10:23 +08:00
Kelvin Mwinuka
8cc8f6c02c Implemented default KeyLock and KeyRLock timeout of 250 milliseconds when timeout is not provided by the caller. 2024-03-11 00:39:06 +08:00
Kelvin Mwinuka
c414da16b4 KeyExists keyspace function now removes the key if the key expiry is in the past.
KeyData type moved to utils package to allow sharing between multiple packages.
Updated all commands and command tests to pass context object to KeyExists, KeyLock, keyUnlock, KeyRLock, and KeyRUnlock.
Create context object for each test in all test suites instead of just passing context.Background() to all functions that accept a context.
2024-03-10 23:19:05 +08:00
Kelvin Mwinuka
10f1aeab9e Implemented handler for EXPIREAT and PEXPIREAT commands 2024-03-10 00:43:23 +08:00
Kelvin Mwinuka
97a10e4fdb Implemented EXPIRTE and PEXPIRE command handler 2024-03-09 23:28:46 +08:00
Kelvin Mwinuka
b7b8ecff4c Implemented PERSIST, EXPIRETIME, PEXPIRETIME, TTL, and PTTL command handlers.
Added keyspace function GetExpiry to get expiry time of a given key.
2024-03-09 01:42:12 +08:00
Kelvin Mwinuka
42289527c3 Set sync to false for all keyspace read commands in the generic module 2024-03-09 00:33:09 +08:00
Kelvin Mwinuka
74c08a5b22 Created KeyData type to hold key data value and expireAt in the same map object. Created scaffolding for PERSIST, EXPIRETIME, PEXPIRETIME, TTL, PTTL, EXPIRE, PEXPIRE, EXPIREAT and PEXPIREAT commands 2024-03-09 00:18:58 +08:00
Kelvin Mwinuka
0b90c9343e Added DEL command for deleting keys from the store 2024-03-08 22:49:03 +08:00
Kelvin Mwinuka
e34ed74e3f Implemented DeleteKey function to delete keys from data store 2024-03-08 20:53:40 +08:00
Kelvin Mwinuka
0b9fbb0132 Added mutexes for lfu and lru caches on server struct 2024-03-08 02:21:26 +08:00
Kelvin Mwinuka
82be1f6068 Added addedTime to EntryLFU object to control which entry will be removed if access count is the same. If two entries have the same access count, the older entry should be removed first.
SetKeyExpiry and GetValue keyspace receiver functions now require context object to be passed.
Created adjustMemoryUsage function for key eviction for LFU, LRU, and Random eviction policies.
Updated all modules to pass context to SetKeyExpirty and GetValue functions.
2024-03-08 00:26:49 +08:00
Kelvin Mwinuka
08d178b917 Added error checking on SetValue in module commands 2024-03-06 17:37:23 +08:00
Kelvin Mwinuka
78b2e337d1 Pass config to IsMaxMemoryExceeded 2024-03-06 15:28:03 +08:00
Kelvin Mwinuka
118e155144 Created IsMaxMemoryExceeded utility function that is used to check whether the server has exceeded the max memory.
Check whether max memory is exceeded before setting value or creating new key.
Return error from SetValue function when max memory is exceeded. This change has been propagated to the aof and snapshot engines as well.
Snapshot engine now only accepts SetValue option. No longer does it neet to use CreateKeyAndLock & KeyUnlock functions itself.
2024-03-06 15:20:45 +08:00
Kelvin Clement Mwinuka
f23bbd481e Track src/aof folder but ignore aof subfolders in modules folder 2024-03-05 22:52:32 +08:00
Kelvin Clement Mwinuka
5c347cb7de Changed max-memory to uint64. Added TODO commends on how to handle memory checking for key eviction. 2024-03-05 22:45:05 +08:00
Kelvin Clement Mwinuka
28f97656c4 Removed etc and get modules and replaced them with generic module. Implemented functions to set and remove the expiry of a key. Implemented LRU and LFU caches using heap. 2024-03-03 16:21:12 +08:00
Kelvin Clement Mwinuka
e569bf6837 Added config flags max-memory and eviction-policy to manage memory usage. Created ParseMemory utility function to parse max-memory value into bytes. Created LFU cache to be used with heap data structure for managing LFU cache. 2024-03-01 16:25:04 +08:00
Kelvin Clement Mwinuka
97b41da729 Moved aof and snapshot packages from server folder to src folder. Created new package for evictions 2024-02-29 16:06:52 +08:00
Kelvin Clement Mwinuka
b9959ed523 Added redis clients statement in clients section in README.md v0.2.0 2024-02-28 21:03:21 +08:00
Kelvin Mwinuka
dbeacc71b7 Merge pull request #10 from EchoVault/enhancement/redis-client-compatibility
Enhancement/redis client compatibility
2024-02-28 20:56:09 +08:00
Kelvin Clement Mwinuka
62ef29c424 Return empty array for COMMAND DOCS because COMMANDS response triggers error in redis-cli 2024-02-28 15:33:39 +08:00
Kelvin Clement Mwinuka
facdc089d8 Implemented command handler for COMMAND LIST command 2024-02-28 15:16:11 +08:00
Kelvin Clement Mwinuka
1a4747db6d Updated GPL badge to v3 and uncommented cluster nodes in docker-compose.yml 2024-02-28 13:35:02 +08:00
Kelvin Clement Mwinuka
131f15dbb6 Trim byte slice from message read to remove null characters. Add and new line after each command printed to the AOF file 2024-02-28 12:02:05 +08:00
Kelvin Clement Mwinuka
91d96bf9b6 Removed extra '\r\n' in admin, set and sorted_set modules 2024-02-28 11:20:18 +08:00
Kelvin Clement Mwinuka
8ca9a770d5 Removed trailing carriage returns and new lines in command responses to make responses compatible with Redis clients 2024-02-28 11:10:28 +08:00
Kelvin Clement Mwinuka
e18257e600 Added PUBSUB commands and made pubsub module more compatible with redis-cli client 2024-02-28 10:14:46 +08:00
Kelvin Clement Mwinuka
6566bb41c4 Removed all usages of custion utils.Filter function in favour of built-in slices DeleteFunc. Updated utils.ReadMessage to read with 8192 sized chunks to reduce the risk of running into a blocking read call when the end of the input is reached. 2024-02-28 06:34:11 +08:00