| 1 |
#ifndef AWS_COMMON_CACHE_H |
| 2 |
#define AWS_COMMON_CACHE_H |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#include <aws/common/linked_hash_table.h> |
| 9 |
|
| 10 |
AWS_PUSH_SANE_WARNING_LEVEL |
| 11 |
|
| 12 |
struct aws_cache; |
| 13 |
|
| 14 |
struct aws_cache_vtable { |
| 15 |
void (*destroy)(struct aws_cache *cache); |
| 16 |
int (*find)(struct aws_cache *cache, const void *key, void **p_value); |
| 17 |
int (*put)(struct aws_cache *cache, const void *key, void *p_value); |
| 18 |
int (*remove)(struct aws_cache *cache, const void *key); |
| 19 |
void (*clear)(struct aws_cache *cache); |
| 20 |
size_t (*get_element_count)(const struct aws_cache *cache); |
| 21 |
}; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
struct aws_cache { |
| 27 |
struct aws_allocator *allocator; |
| 28 |
const struct aws_cache_vtable *vtable; |
| 29 |
struct aws_linked_hash_table table; |
| 30 |
size_t max_items; |
| 31 |
|
| 32 |
void *impl; |
| 33 |
}; |
| 34 |
|
| 35 |
|
| 36 |
void aws_cache_base_default_destroy(struct aws_cache *cache); |
| 37 |
int aws_cache_base_default_find(struct aws_cache *cache, const void *key, void **p_value); |
| 38 |
int aws_cache_base_default_remove(struct aws_cache *cache, const void *key); |
| 39 |
void aws_cache_base_default_clear(struct aws_cache *cache); |
| 40 |
size_t aws_cache_base_default_get_element_count(const struct aws_cache *cache); |
| 41 |
|
| 42 |
AWS_EXTERN_C_BEGIN |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
AWS_COMMON_API |
| 48 |
void aws_cache_destroy(struct aws_cache *cache); |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
AWS_COMMON_API |
| 57 |
int aws_cache_find(struct aws_cache *cache, const void *key, void **p_value); |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
AWS_COMMON_API |
| 64 |
int aws_cache_put(struct aws_cache *cache, const void *key, void *p_value); |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
AWS_COMMON_API |
| 70 |
int aws_cache_remove(struct aws_cache *cache, const void *key); |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
AWS_COMMON_API |
| 76 |
void aws_cache_clear(struct aws_cache *cache); |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
AWS_COMMON_API |
| 82 |
size_t aws_cache_get_element_count(const struct aws_cache *cache); |
| 83 |
|
| 84 |
AWS_EXTERN_C_END |
| 85 |
AWS_POP_SANE_WARNING_LEVEL |
| 86 |
|
| 87 |
#endif |