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.
This commit is contained in:
Kelvin Mwinuka
2024-03-08 00:26:49 +08:00
parent 08d178b917
commit 82be1f6068
18 changed files with 330 additions and 147 deletions

View File

@@ -138,7 +138,7 @@ func Test_HandleSetRange(t *testing.T) {
if _, err = mockServer.KeyRLock(context.Background(), test.key); err != nil {
t.Error(err)
}
value, ok := mockServer.GetValue(test.key).(string)
value, ok := mockServer.GetValue(context.Background(), test.key).(string)
if !ok {
t.Error("expected string data type, got another type")
}