node: Refactor TTL cache #831

Merged
fyrchik merged 1 commit from achuprov/frostfs-node:ttl_cache into master 2023-11-30 12:54:53 +00:00
Member

Migrate from internal to external TTL implementation

Closes: #639

Signed-off-by: Alexander Chuprov a.chuprov@yadro.com

Migrate from internal to external TTL implementation Closes: #639 Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
requested reviews from storage-core-committers, storage-core-developers 2023-11-29 13:28:58 +00:00
aarifullin reviewed 2023-11-29 14:31:02 +00:00
@ -0,0 +27,4 @@
cache.set(key, ti, nil)
time.Sleep(2 * ttlDuration)
val, err := cache.get(key)
assert.Nil(t, err)
Member

-> assert.NoError? :)

-> `assert.NoError`? :)

require.NoError better

`require.NoError` better
Author
Member

fixed

fixed
aarifullin reviewed 2023-11-29 14:32:33 +00:00
@ -0,0 +28,4 @@
time.Sleep(2 * ttlDuration)
val, err := cache.get(key)
assert.Nil(t, err)
assert.NotEqual(t, val, ti)
Member

Am I right that values are not equeal because the entry is expired after time.Sleep(2 * ttlDuration)?

Am I right that values are not equeal because the entry is expired after `time.Sleep(2 * ttlDuration)`?
Author
Member

Yes, you are correct. The values are not equal because the entry has expired after the time.Sleep(2 * ttl Duration) interval

Yes, you are correct. The values are not equal because the entry has expired after the `time.Sleep(2 * ttl Duration)` interval
fyrchik approved these changes 2023-11-29 15:26:21 +00:00
@ -33,3 +29,1 @@
netRdr netValueReader[K, V]
cache *expirable.LRU[K, *valueWithTime[V]]
Owner

If it is expireable, why do we use *valueWithTime[V] instead of *V?

If it is expireable, why do we use `*valueWithTime[V]` instead of `*V`?
Owner

Approved by accident, please disregard.

Approved by accident, please disregard.
Author
Member

fixed

fixed
fyrchik marked this conversation as resolved
achuprov force-pushed ttl_cache from ac06af2940 to b9441b3479 2023-11-30 08:37:05 +00:00 Compare
achuprov force-pushed ttl_cache from b9441b3479 to 30b237e176 2023-11-30 08:46:09 +00:00 Compare
dstepanov-yadro approved these changes 2023-11-30 11:53:49 +00:00
fyrchik approved these changes 2023-11-30 12:53:37 +00:00
fyrchik merged commit 7f6852bbd2 into master 2023-11-30 12:54:53 +00:00
Sign in to join this conversation.
No reviewers
TrueCloudLab/storage-core-developers
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-node#831
No description provided.