-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcache.h
41 lines (35 loc) · 851 Bytes
/
cache.h
1
2
3
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
/*
* Copyright 2022 zhenwei pi
*
* Authors:
* zhenwei pi <[email protected]>
*
* This work is licensed under the terms of the GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
*/
#ifndef _CACHE_H_
#define _CACHE_H_
#include <sys/types.h>
#include <time.h>
struct cache_elem_t {
time_t time;
off_t off;
};
struct cache_t {
char *name;
int flags;
int max_elems;
int nr_elems;
struct cache_elem_t *elems;
off_t st_size;
struct timespec st_mtim;
};
struct cache_t *cache_alloc(const char *name);
struct cache_t *cache_find(const char *name);
void cache_free(const char *name);
void cache_set(struct cache_t *cache, time_t time, off_t off);
struct cache_t *cache_get(time_t time, off_t *off);
void cache_done(struct cache_t *cache);
void cache_sort();
struct cache_t *cache_get_recent();
#endif