From: Robert K. <may...@us...> - 2001-10-12 19:59:55
|
Update of /cvsroot/bitcollider/bitcollider/include In directory usw-pr-cvs1:/tmp/cvs-serv28703/include Modified Files: bitcollider.h cache.h defs.h Log Message: Next set of improvements to the cache support. The cache now has a size limit (by default 8192 entries). If the cache grows past 8192, then remove 10% of the least recently used entries. Also I've added support for making sure the database gets cleaned up properly at exit. Index: bitcollider.h =================================================================== RCS file: /cvsroot/bitcollider/bitcollider/include/bitcollider.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** bitcollider.h 2001/10/10 23:25:48 1.10 --- bitcollider.h 2001/10/12 19:59:51 1.11 *************** *** 43,46 **** --- 43,47 ---- #if USE_BDB cache_info *cache; + int maxCacheSize; #endif } Bitcollider; *************** *** 82,85 **** --- 83,87 ---- void set_exit (Bitcollider *bc, b_bool enable); + void clear_bitprint_cache(Bitcollider *bc); Index: cache.h =================================================================== RCS file: /cvsroot/bitcollider/bitcollider/include/cache.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** cache.h 2001/10/10 23:25:48 1.1 --- cache.h 2001/10/12 19:59:51 1.2 *************** *** 12,19 **** #include "bitprint.h" typedef struct _cache_info { DB *dbp; ! char *errorString; } cache_info; --- 12,23 ---- #include "bitprint.h" + #define ERR_STRING_LEN 1024 + typedef struct _cache_info { DB *dbp; ! char errorString[ERR_STRING_LEN]; ! int maxCount; ! char fileName[MAX_PATH]; } cache_info; *************** *** 23,37 **** time_t lastModDate; char bitprint[BITPRINT_BASE32_LEN]; } cache_entry; cache_info *init_cache(void); b_bool open_cache(cache_info *info, const char *fileName); void close_cache(cache_info *info); /* Fill out the fileName in the cache entry and get will fill out the other fields. */ ! b_bool get_cache_entry(cache_info *info, cache_entry *entry); ! b_bool add_cache_entry(cache_info *info, cache_entry *entry); ! b_bool remove_cache_entry(cache_info *info, cache_entry *entry); #endif --- 27,58 ---- time_t lastModDate; char bitprint[BITPRINT_BASE32_LEN]; + time_t lastUsedDate; } cache_entry; cache_info *init_cache(void); b_bool open_cache(cache_info *info, const char *fileName); + b_bool create_cache(cache_info *info, const char *fileName, int maxCount); void close_cache(cache_info *info); /* Fill out the fileName in the cache entry and get will fill out the other fields. */ ! b_bool get_cache_entry(cache_info *info, cache_entry *entry); ! ! /* Add an entry to the cache. Set update to true and the add function ! updates an existing record. */ ! b_bool add_cache_entry(cache_info *info, cache_entry *entry, b_bool update); ! ! /* Remove a record from the cache. The key in the entry must be set */ ! b_bool remove_cache_entry(cache_info *info, cache_entry *entry); ! ! /* Remove the numEntries least recently used entries */ ! b_bool remove_excessive_entries(cache_info *info, int curCount); ! ! /* Internal functions: */ ! b_bool set_count(cache_info *info, int count); ! int get_count(cache_info *info); ! ! b_bool set_max_count(cache_info *info, int count); ! int get_max_count(cache_info *info); #endif Index: defs.h =================================================================== RCS file: /cvsroot/bitcollider/bitcollider/include/defs.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** defs.h 2001/10/10 23:25:48 1.1 --- defs.h 2001/10/12 19:59:51 1.2 *************** *** 29,32 **** --- 29,34 ---- #endif + #define DEFAULT_MAX_CACHE_SIZE 8192 + #ifdef __cplusplus } |