Lars Hjemli | ee4056b | 2008-03-27 09:22:13 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Since git has it's own cache.h which we include, |
| 3 | * lets test on CGIT_CACHE_H to avoid confusion |
| 4 | */ |
| 5 | |
| 6 | #ifndef CGIT_CACHE_H |
| 7 | #define CGIT_CACHE_H |
| 8 | |
Lukas Fleischer | f60ffa1 | 2014-01-15 21:53:15 +0100 | [diff] [blame] | 9 | typedef void (*cache_fill_fn)(void); |
Lars Hjemli | ee4056b | 2008-03-27 09:22:13 +0100 | [diff] [blame] | 10 | |
Lars Hjemli | 939d32f | 2008-04-28 11:32:42 +0200 | [diff] [blame] | 11 | |
| 12 | /* Print cached content to stdout, generate the content if necessary. |
| 13 | * |
| 14 | * Parameters |
| 15 | * size max number of cache files |
| 16 | * path directory used to store cache files |
| 17 | * key the key used to lookup cache files |
| 18 | * ttl max cache time in seconds for this key |
| 19 | * fn content generator function for this key |
Lars Hjemli | 939d32f | 2008-04-28 11:32:42 +0200 | [diff] [blame] | 20 | * |
| 21 | * Return value |
| 22 | * 0 indicates success, everyting else is an error |
| 23 | */ |
| 24 | extern int cache_process(int size, const char *path, const char *key, int ttl, |
Lukas Fleischer | f60ffa1 | 2014-01-15 21:53:15 +0100 | [diff] [blame] | 25 | cache_fill_fn fn); |
Lars Hjemli | 939d32f | 2008-04-28 11:32:42 +0200 | [diff] [blame] | 26 | |
| 27 | |
Lars Hjemli | 9000bbf | 2008-04-28 12:10:13 +0200 | [diff] [blame] | 28 | /* List info about all cache entries on stdout */ |
| 29 | extern int cache_ls(const char *path); |
| 30 | |
Lars Hjemli | 939d32f | 2008-04-28 11:32:42 +0200 | [diff] [blame] | 31 | /* Print a message to stdout */ |
Mark Lodato | a4c58d9 | 2010-09-04 11:09:57 -0400 | [diff] [blame] | 32 | __attribute__((format (printf,1,2))) |
Lars Hjemli | 939d32f | 2008-04-28 11:32:42 +0200 | [diff] [blame] | 33 | extern void cache_log(const char *format, ...); |
Lars Hjemli | ee4056b | 2008-03-27 09:22:13 +0100 | [diff] [blame] | 34 | |
Lars Hjemli | 523a216 | 2009-08-19 17:43:47 +0200 | [diff] [blame] | 35 | extern unsigned long hash_str(const char *str); |
| 36 | |
Lars Hjemli | ee4056b | 2008-03-27 09:22:13 +0100 | [diff] [blame] | 37 | #endif /* CGIT_CACHE_H */ |