Giter Site home page Giter Site logo

c-lru-cache's Introduction

C LRU Cache

A simple least recently used cache written in C.

Usage

Select a maximum size for the cache to grow to (e.g 60MB), determine the average size of items in the cache (a guess is OK), then use the cache using five functions:

// cache size, and hypothetical item #define MAX_SIZE (60 * 1024 * 1024) #define AVG_SIZE (2 * 1024) void *key = (void *)“test”; int key_length = 4; void *item = (void *)“value”; int item_length = 5; // create a new cache lru_cache *cache = lru_cache_new(MAX_SIZE, AVG_SIZE); // set an item lru_cache_set(cache, key, key_length, item, item_length); // get an item lru_cache_get(cache, key, key_length, &item); // delete an item lru_cache_delete(cache, key, key_length); // free a cache lru_cache_free(cache);

Implementation

There are no external dependencies.

c-lru-cache's People

Contributors

willcannings avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.