https://github.com/mfernstrom/fpcache
An in-memory caching manager for FreePascal
https://github.com/mfernstrom/fpcache
caching fpc freepascal lazarus performance
Last synced: about 2 months ago
JSON representation
An in-memory caching manager for FreePascal
- Host: GitHub
- URL: https://github.com/mfernstrom/fpcache
- Owner: MFernstrom
- License: mit
- Created: 2018-12-04T15:22:22.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-07-18T02:49:45.000Z (10 months ago)
- Last Synced: 2025-03-19T21:45:09.307Z (2 months ago)
- Topics: caching, fpc, freepascal, lazarus, performance
- Language: Pascal
- Size: 14.6 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
FPCache is a simple in-memory cache manager for FreePascal with optional data lifespan.
## Usage
uses fpcache;var
cache: TCache;
begin
cache := TCache.Create
// Put my name into the cache
cache.put('name', 'Marcus');
// Get and WriteLn my name
WriteLn(cache.getStr('name'));
// Remove my name from the cache
cache.delete('name');
// Put my age with a data lifespan of 10 seconds
cache.put('age', 32, 10000);
// Get and print my age
WriteLn(cache.getInt('age'));
// Blank string
WriteLn(cache.getStr('nope'));
// Integer 0
WriteLn(cache.getInt('nope'));
// throwOnMissing is optional and defaults to false
cache.throwOnMissing := true;
// Now we get an exception
WriteLn(cache.getStr('nope'));// Don't forget to free the cache when you're done
cache.free;
end;