Skip to content

Latest commit

 

History

19 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LRU Cache Express

A clean and efficient fixed-capacity Least Recently Used (LRU) cache implemented in pure C.

The project focuses on data-structure design, predictable performance, memory management, and a small reusable API.

Overview

An LRU cache keeps recently accessed items available while automatically evicting the least recently used item when its capacity is reached.

LRUCacheExpress provides average O(1) get and put operations.

Features

  • Fixed-capacity LRU cache
  • O(1) average-time get
  • O(1) average-time put
  • Modular C implementation
  • Reusable public API
  • Dedicated tests
  • Explicit memory management

Complexity

Operation Average
Get O(1)
Put O(1)
Eviction O(1)

The constant-time design is achieved by combining fast lookup with an ordering structure that tracks recent usage.

Project Structure

LRUCacheExpress/
├── includes/
├── sources/
├── tests/
├── LICENSE
└── README.md

Building

The project is written in C. A typical build can be performed with:

cc -Iincludes sources/*.c -o lru_cache

Adapt the command to the compiler and source files required by your environment.

Testing

The repository contains a dedicated tests/ directory for validating cache behavior.

Typical cases to test include:

  • Inserting new entries
  • Updating existing entries
  • Reading an existing key
  • Reading a missing key
  • Capacity overflow
  • Least-recently-used eviction
  • Repeated access and recency updates

Why This Project?

The goal is to demonstrate how a commonly used systems/data-structure concept can be implemented from scratch in C while keeping the public API small and the runtime characteristics predictable.

License

MIT License.

About

A clean and efficient Least Recently Used (LRU) cache written in C, focusing on performance and memory efficiency

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages