Skip to content

Add memory limits and eviction policy #73

@AlexJuca

Description

@AlexJuca

Context

FKVS currently accepts writes until the process runs out of memory. Production deployments need predictable memory behavior: configured memory ceilings, metrics, and an eviction or rejection strategy.

Relevant code:

  • src/core/hashtable.c
  • src/server.h
  • src/memory.c
  • src/commands/server/server_command_handlers.c

Scope

  • Add configurable maximum memory usage.
  • Track memory used by keys, values, hash table entries, client buffers, TTL metadata, and persistence buffers where applicable.
  • Decide policy when memory is exhausted: reject writes, evict keys, or support both modes.
  • If eviction is implemented, define algorithm and metadata requirements (e.g. approximate LRU/LFU/random/TTL-first).
  • Expose memory limit, current memory, rejected writes, and evictions through INFO/metrics.

Acceptance criteria

  • A configured memory limit is enforced deterministically.
  • Write commands fail gracefully or evict according to configuration when the limit is reached.
  • Memory accounting is covered by tests.
  • Behavior is documented in README/server config docs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions