Skip to content

Conversation

@JimB123
Copy link
Member

@JimB123 JimB123 commented Nov 19, 2025

General cleanup on LRU/LFU code. Improve modularity and maintainability.

Specifically:

  • Consolidates the mathematical logic for LRU/LFU into lrulfu.c, with an API in lrulfu.h. Knowledge of the LRU/LFU implementation was previously spread out across db.c, evict.c, object.c, server.c, and server.h.
  • Separates knowledge of the LRU from knowledge of the object containing the LRU value. lrulfu.c knows about the LRU/LFU algorithms, without knowing about the robj. object.c knows about the robj without knowing about the details of the LRU/LFU algorithms.
  • Eliminated server.lruclock, instead using server.unixtime. This also eliminates the periodic need to call mstime() to maintain the lru clock.
  • Fixed a minor computation bug in the old LFUTimeElapsed function (off by 1 after rollover).
  • Eliminate specific IF checks for rollover, using defined behavior for unsigned rollover instead.
  • Fixed a bug in debug.c which would perform LFU modification on an LRU value.

Signed-off-by: Jim Brunner <brunnerj@amazon.com>
@JimB123 JimB123 marked this pull request as ready for review November 19, 2025 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant