PerfCache Home
A high-performance C++ cache library implementing O(1) LRU and LFU.
Status: Alpha
Brought to you by:
ghofford
Method: InitializeEx
int InitializeEx (enum KeyType keyType,
unsigned int lenMaxStringKeyInUnits,
enum KeyStorageMethod keyStorageMethod,
bool fReplaceDuplicateKeyCacheEntry,
const unsigned int numSecondsTTLDefault,
const UINTEGER32 numDirectoryElementsToAllocate,
struct HashFunctionStructure pHashFunctionStructure,
const UINTEGER32 sizeCache,
enum ReplacementPolicy replacementPolicy,
struct GlobalConfiguration pGlobalConfiguration,
bool fDEBUG,
CLogger *pLogger);
Parameters:
1) keyType: only KeyTypeByteString is currently supported
2) lenMaxStringKeyInUnits must include space for a null-terminator byte
or word if one is needed. For example: if the max key length in words
is 128, including space for a null terminator, lenMaxStringKeyInUnits
must be 128.
3) keyStorageMethod: only MapHashTable is currently supported
4) fReplaceDuplicateKeyCacheEntry: a global setting, which causes the Insert
methods to replace duplicate key cache entries.
5) numSecondsTTLDefault: the default Time-to-live (TTL) value
6) pHashFunctionStructure: must point to a HashFunctionStructure that has
been initialized with a hash function.
7) replacementPolicy: LRU or LFU
8) numDirectoryElementsToAllocate: size of map (hash table). A typical value
would be 133% the size of the cache. (E.g. if cache size = 1000, this would be 1333).
9) sizeCache: the number of entries (array elements) of the cache
10) pGlobalConfiguration: a pointer to a GlobalConfiguration structure (may be NULL,
if custom global configuration settings are not needed).
11) fDEBUG: for debugging
12) pLogger: a pointer to an initialized CLogger object.
Return values:
E_CACHE_INITIALIZATION_INVALID_KEYTYPE_FOR_MAPHASHTABLE
E_INSUFFICIENTMEMORY
E_CACHE_INITIALIZATION_INVALID_KEYSTORAGEMETHOD
E_KEY_INVALIDKEYTYPE
E_CACHE_INITIALIZATION_CACHESIZE_TOO_SMALL
E_CACHE_INITIALIZATION_INVALID_REPLACEMENTPOLICY
E_LOGGINGFUNCTION_MISSING
E_SUCCESS