cache.h 4.33 KB
Newer Older
Per Cederqvist's avatar
Per Cederqvist committed
1
/*
2
 * $Id: cache.h,v 0.6 1991/09/05 08:32:51 ceder Exp $
Per Cederqvist's avatar
Per Cederqvist committed
3
 *
Per Cederqvist's avatar
Per Cederqvist committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
 * This file contains the cached data that the server stores.
 * .h file created by ceder 1990-04-18
 */

/* cache_sync_all only returns when everything is written to disk. */
extern void
cache_sync_all(void);


/* First, some things which I want here. /ceder */

extern struct matching_info *match_table;

extern void
cached_lock_conf(Conf_no conf_no);

extern Success
init_cache(void);

extern void
cached_unlock_conf(Conf_no conf);

extern void
cached_lock_person(Pers_no pers);

extern void
cached_unlock_person(Pers_no pers);

extern Success
cached_delete_person(Pers_no pres);

extern Success
cached_delete_text(Text_no text);

extern Success
build_matching_info(void);

extern void			/* Write out everything. */
cache_sync(void);

/* S}d{r ja. Tack f|r mig. /ceder */

#define	MAX_CACHED_PERSONS	5	/* To be increased after debugging */
#define MAX_CACHED_WHATEVER		/* To be added	*/


/*
 * Name caching routines
 */

/*
 * change_name changes the cached conference name. It is only called when
 * a conference name is changed or a conference is deleted.
 *
 * cached_change_name(foo, EMPTY_STRING); should be used when a conference
 * is deleted. (Eller ska det vara annorlunda? S} g|r jag nu... /ceder)
 */
extern void
cached_change_name(Conf_no name_num,
		   String  new_name );


/* add_name adds a name to the list of cached conference names. It is only
 * used when a new conference is created.
 */
extern void
cached_add_name( char * new_name );

/* load all the conference names from disk and store them in memory */
extern void
cached_load_names( void );

#if 0
/* get one name (I want this call! /ceder) */
/* I no longer want it. */
extern String
cached_get_name( Conf_no conf_no );	/* Returns NULL if the conference */
					/* doesn't exist. */
#endif

extern Bool
cached_conf_exists( Conf_no conf_no );

/*
 * Calls for the cacheing of conf_type:
89 90
 * cached_get_conf_type() returns the type.
 * The type is set when mark_conference_as_changed is called.
Per Cederqvist's avatar
Per Cederqvist committed
91 92 93 94 95 96 97 98 99
 */

/* Get conference type */
/* Undefined result if the conf doesn't exist. */

extern Conf_type
cached_get_conf_type (Conf_no conf_no);

/*
100 101
 * Get garb_nice for a certain conference.
 * It is set when mark_conference_as_changed is called.
Per Cederqvist's avatar
Per Cederqvist committed
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
 */
extern Garb_nice
cached_get_garb_nice (Conf_no conf_no);

extern Local_text_no
cached_get_highest_local_no (Conf_no conf_no);



/*
 * Person caching routines
 */
#if 0
extern Person *
cached_read_person( Pers_no pers_no );
#endif
/*
 * Various function calls to tell the cache that something is changed.
 */

void
mark_person_as_changed(Pers_no	pers_no);


void
mark_conference_as_changed(Conf_no	conf_no);


void
mark_text_as_changed(Text_no	text_no);




/*
 * Person-related calls
 */

extern Success
cached_create_person( Pers_no person );



extern Person *
cached_get_person_stat( Pers_no	person );	/* Returns NULL if person
						   doesn't exist */



/*
 * Conference-related calls
 */
extern Conf_no
cached_create_conf( String  name );


extern Success
cached_delete_conf( Conf_no	conf );

extern Success
cached_lookup_name(const String   name,
		   Conf_list_old *result);

extern Conference *
cached_get_conf_stat(	Conf_no		conf_no );


/*
 * Calls to handle texts
 */

extern String
cached_get_text( Text_no text );/* The string should be free'd by the caller */

extern Text_stat *
cached_get_text_stat(	Text_no		text );


extern Text_no
cached_create_text( String message);

/*
 * traverse_text can be used to cycle through all existing texts. 0 will
 * be returned once in the "cycle".
 */
extern Text_no
traverse_text(Text_no seed);

/*
 * traverse_person can be used to cycle through all existing persons. 0 will
 * be returned once in the "cycle".
 */
extern Pers_no
traverse_person(Pers_no seed);

/*
 * traverse_conference can be used to cycle through all existing conferences.
 * 0 will be returned once in the "cycle".
 */
extern Conf_no
traverse_conference(Conf_no seed);
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217

/*
 * Free all memory used by the cache. This should only be done
 * as part of the shutdown sequence. The purpose of this is to
 * make it possible to see if there are any memory leaks.
 */

void
free_all_cache(void);

/*
 * Limit the number of 'clean' cache entries.
 */
void
cache_limit_size(void);
218 219 220 221 222 223 224 225 226 227 228 229

/*
 * Dump cache statistics.
 */

void
dump_cache_stats(FILE *stat_file);

/*
 * Dump memory usage.
 */
void
Per Cederqvist's avatar
Per Cederqvist committed
230
dump_cache_mem_usage(FILE *stat_file);