PerfCache Wiki
A high-performance C++ cache library implementing O(1) LRU and LFU.
Status: Alpha
Brought to you by:
ghofford
InsertString() inserts a byte or character string, including the trailing NULL, into a cache entry within the cache. InsertString() has two overloads, differing by key type; however both overloads for this method insert a string of bytes, or single-byte characters, not wide characters, into the cache.
int InsertString (const QBYTE *szKey,
const QBYTE *pbszData,
const unsigned int numSecondsTTL);
int InsertString (const QWORD *wszKey,
const QBYTE *pbszData,
const unsigned int numSecondsTTL);
1) szKey or wszKey: the key
2) pbszData: a pointer to a buffer of bytes that will be inserted into the cache.
3) numSecondsTTL: number of seconds for the "time-to-live" value.
E_KEY_INVALIDKEYTYPE
E_INVALID_KEYVALUE
E_CACHE_DUPLICATE_KEY_FOUND_ENTRY_NOT_REPLACED
E_SUCCESS
The InsertString() method inserts a key and an associated byte string value into the cache. If the cache is full, a replacement is performed; the type of replacement is dependent on the cache replacement policy.
// (initialize cache here)
int iResult = pCache->InsertString ((QBYTE *) "AA", // key
(QBYTE *) "aaaaa", // char string value
0); // TTL
if (iResult != E_SUCCESS)
{
// error handling here
}