diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2024-07-24 18:54:07 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska@appnovation.com> | 2024-07-24 18:54:07 +0000 |
| commit | 8c9b0194063411882d3bbcec80d5e5c861d37544 (patch) | |
| tree | 92d6ed8a8d5e8b35958bd45ebc3aa45b5105db9a /src/cache/cache.c | |
| parent | 8d5a23bf7fe6bda50bab13f12725f3b7c8976d29 (diff) | |
| download | shibari-8c9b0194063411882d3bbcec80d5e5c861d37544.tar.gz | |
Add stuff to shibari-cache
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/cache/cache.c')
| -rw-r--r-- | src/cache/cache.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/cache/cache.c b/src/cache/cache.c index 8c820fb..186450c 100644 --- a/src/cache/cache.c +++ b/src/cache/cache.c @@ -1,6 +1,36 @@ /* ISC license. */ +#include <skalibs/uint64.h> +#include <skalibs/posixplz.h> +#include <skalibs/strerr.h> + #include <shibari/dcache.h> #include "shibari-cache-internal.h" -dcache_t cache = DCACHE_ZERO ; +static dcache_t cache = DCACHE_ZERO ; + +void cache_init (uint64_t cachesize) +{ + dcache_init(&cache, cachesize) ; +} + +void cache_dump (void) +{ + if (g->dumpfile) + { + if (!dcache_save(&cache, g->dumpfile)) + { + strerr_warnwu2sys("save cache contents to ", g->dumpfile) ; + unlink_void(file) ; + } + } +} + +void cache_load (void) +{ + if (g->dumpfile) + { + if (!dcache_load(&cache, g->dumpfile)) + strerr_warnwu2sys("load cache contents from ", g->dumpfile) ; + } +} |
