valkey
valkey copied to clipboard
Refactor of LFU/LRU code for modularity
General cleanup on LRU/LFU code. Improve modularity and maintainability.
Specifically:
- Consolidates the mathematical logic for LRU/LFU into
lrulfu.c, with an API inlrulfu.h. Knowledge of the LRU/LFU implementation was previously spread out acrossdb.c,evict.c,object.c,server.c, andserver.h. - Separates knowledge of the LRU from knowledge of the object containing the LRU value.
lrulfu.cknows about the LRU/LFU algorithms, without knowing about therobj.object.cknows about therobjwithout knowing about the details of the LRU/LFU algorithms. - Eliminated
server.lruclock, instead usingserver.unixtime. This also eliminates the periodic need to callmstime()to maintain the lru clock. - Fixed a minor computation bug in the old
LFUTimeElapsedfunction (off by 1 after rollover). - Eliminate specific IF checks for rollover, using defined behavior for unsigned rollover instead.
- Fixed a bug in
debug.cwhich would perform LFU modification on an LRU value.