Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works

Random project

fpcache

An in-memory caching manager for FreePascal

View on GitHub

Anyone may press Interesting, signed in or not. It helps others find this project.

Member rating

No ratings yet.

Sign in to rate this project.

README

FPCache is a simple in-memory cache manager for FreePascal with optional data lifespan.

Usage

<pre> uses fpcache;

var cache: TCache;

begin cache := TCache.Create

pascal
// Put my name into the cache
cache.put('name', 'Marcus');
pascal
// Get and WriteLn my name
WriteLn(cache.getStr('name'));
pascal
// Remove my name from the cache
cache.delete('name');
pascal
// Put my age with a data lifespan of 10 seconds
cache.put('age', 32, 10000);
pascal
// Get and print my age
WriteLn(cache.getInt('age'));
pascal
// Blank string
WriteLn(cache.getStr('nope'));
pascal
// Integer 0
WriteLn(cache.getInt('nope'));
pascal
// throwOnMissing is optional and defaults to false
cache.throwOnMissing := true;
pascal
// Now we get an exception
WriteLn(cache.getStr('nope'));
pascal
// Don't forget to free the cache when you're done
cache.free;

end; </pre>