Menu

InsertString Method

Method: Cache::InsertString
Summary:

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.


Syntax:
int InsertString (const QBYTE *szKey, 
                  const QBYTE *pbszData,
                  const unsigned int numSecondsTTL);

int InsertString (const QWORD *wszKey, 
                  const QBYTE *pbszData,
                  const unsigned int numSecondsTTL);


Parameters:
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.


Return values:
  E_KEY_INVALIDKEYTYPE
  E_INVALID_KEYVALUE
  E_CACHE_DUPLICATE_KEY_FOUND_ENTRY_NOT_REPLACED
  E_SUCCESS


Remarks:

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.


Example
// (initialize cache here)

int iResult = pCache->InsertString ((QBYTE *) "AA",     // key
                                    (QBYTE *) "aaaaa",  // char string value
                                    0);                 // TTL
if (iResult != E_SUCCESS)
{
    // error handling here
}

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.