#ifndef MPLIB1_DL_LRU_PRIVATE_H #define MPLIB1_DL_LRU_PRIVATE_H /* ******************************************************************************* * Copyright (c) 1996 Martin Poole * ******************************************************************************* ** ** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! ** ** Any changes to be made to this file should first be checked with ** mplib1 source control for library integrity. ** ** mplib1 source control can be reached at mplib1@quatermass.co.uk ** * * $Source: /home/cvs/cvsroot/onelan/onelan/src/mplib1/include/dl_lru_private.h,v $ * $Author: mpoole $ * $Date: 2002/10/07 09:37:49 $ * $Revision: 1.2 $ * Purpose : private definitions for the cache routines * ******************************************************************************* * * Change History * * $Log: dl_lru_private.h,v $ * Revision 1.2 2002/10/07 09:37:49 mpoole * Initial checkin of mplib1-3.1.0 * * Revision 1.1 2002/10/07 09:36:50 mpoole * Initial checkin of mplib1-3.1.0 * * ******************************************************************************* */ #ident "$Header: /home/cvs/cvsroot/onelan/onelan/src/mplib1/include/dl_lru_private.h,v 1.2 2002/10/07 09:37:49 mpoole Exp $" #ifdef CXREF #include #include #include #endif struct Full_List { dl_List_t fl_Search_List; dl_List_t fl_LRU_List; const char *fl_Name; }; #define FULL_LIST_SIZE sizeof(struct Full_List) struct Cache_List { dl_Node_t cl_Node; /* links us into the Master List */ char *cl_Name; /* Name of this list, (cursor name) */ dl_List_t cl_Fields; /* List of fields (definitions) */ struct Full_List cl_Items; /* List of items */ dl_List_t cl_Free; /* free items */ dl_List_t cl_Free_cgi; /* free cgi items */ dl_List_t cl_Build; /* build list for new items */ dl_List_t cl_Missing; /* list for missing items */ int cl_flags; /* how we will check this list */ size_t cl_data_size; /* size of data block allocated for each item */ int cl_max_items; /* How many items allowed on list */ int cl_curr_items; /* how many so far */ int cl_max_field_num; /* current maximum field number */ int cl_cache_replaces; /* how many times did we re-use */ int cl_cache_hits; /* found an entry */ int cl_cache_misses; /* oh dear */ int cl_complete_misses; /* If they care to tell us */ int cl_expire_seconds; /* How long an item is allowed to live */ int cl_num_search_rules; /* How many rules in the next array */ struct full_search_rule *cl_search_rules; /* How to search */ time_t cl_create_time; /* when was this created */ int cl_expire_time; /* How many seconds till expiry */ }; struct Cache_Field { dl_Node_t cf_Node; /* to link into cl_Field list */ char *cf_Name; int cf_field_num; int cf_field_type; #define CF_INT 1 #define CF_DOUBLE 2 #define CF_CHAR 3 #define CF_STRING 4 #define CF_VARCHAR 5 #define CF_NUM_FIELD_TYPES 6 int cf_field_flags; #define CF_FLG_IGNORECASE BIT(0) int cf_f_offset; /* field offset from item base */ size_t cf_field_size; /* and length within data block */ }; struct Cache_Item { dl_Node_t ci_S_Node; /* to link us into the cl_Items Search list */ dl_Node_t ci_L_Node; /* to link us into the cl_Items LRU list */ char *ci_Name; /* index field */ size_t ci_data_size; /* size of allocated block */ size_t ci_str_size; /* size of the original string */ void *ci_Item; /* pointer to block containing data */ time_t ci_expire_time; /* When this item is to be aged */ }; struct Cache_Group_Item { struct Cache_Item cgi_Item; /* Allow for normal data */ struct Full_List cgi_Items; /* Next list for searching */ int cgi_Flags; int cgi_cache_replaces; /* how many times did we re-use */ int cgi_cache_hits; /* found an entry */ int cgi_cache_misses; /* oh dear */ int cgi_complete_misses; /* If they care to tell us */ }; struct full_search_rule { struct Cache_Field *cf; int comparison_method; int (*cmpfunc)( void *, void * ); /*off_t cf_f_offset;*/ }; #define CGI_COMPLETE_MISS BIT(0) #define CACHE_LIST_SIZE sizeof(struct Cache_List) #define CACHE_FIELD_SIZE sizeof(struct Cache_Field) #define CACHE_ITEM_SIZE STRUCT_PAD(sizeof(struct Cache_Item)) /* In dl_lru (normal caching) ------------------------------ */ extern struct Full_List * Init_Full_List ( struct Full_List *list, const char *name, int flags ); extern void * Find_Full_Item ( struct Full_List *flist, const char *name ); extern dl_List_t * Get_Cache_Master_List( void ); extern void * Cache_Alloc_Lump( size_t sz, const char *name, char **new_name ); extern struct Cache_List * New_Cache_List( const char *list_name, int max_items, int flags, int defaults, int last_ditch ); extern int Cache_Build_Field_List( struct Cache_List *cl, const char *format_str, const char *field_names ); extern struct Cache_Item * Cache_Find_Simple_Item( struct Cache_List *cl, const char *keys, int *rv ); /* In dl_lru_range (range caching) ------------------------------ */ extern struct Cache_Item * Cache_Find_Requested_Item( struct Cache_List *cl, const void *keys, int *rv ); extern struct Cache_Item * Cache_Get_Item_From_Free( struct Cache_List *cl ); extern int Cache_End_Of_Many( struct Cache_List *cl ); extern int Range_Complete_Miss( struct Cache_List *cl, const void *keys ); extern int Range_Flush( struct Cache_List *cl ); #endif /* -- End of File -- */