pai System & Utilities
cache
In-memory cache for PascalAI with TTL (time-to-live) expiry, LRU eviction, and usage statistics.
Install ppm install cache
Usage Example
uses cache; // Store a value (no TTL) Set('user:1', userData); // Store with TTL (seconds) Set('session:abc', sessionData, 3600); // expires in 1 hour // Retrieve var data := Get('user:1'); if data = Null then WriteLn('Cache miss'); // Check existence without fetching if Has('session:abc') then WriteLn('Session active'); // Delete an entry Delete('user:1'); // Clear all entries Clear; // Get hit/miss statistics var stats := GetStats; WriteLn('Hits: ' + IntToStr(stats.Hits));
Features
Set: store any PascalAI value with optional TTL
Get: retrieve value or Null if expired/missing
Has: check key presence without fetching
Delete: remove a specific entry
Clear: remove all cached entries
GetStats: hit rate, miss count, entry count
LRU eviction when memory limit is reached
← Back to Package Index