Debian Codegraph @

crt/aws-c-common/include/aws/common/lru_cache.h

raw symbols SCIP
1 #ifndef AWS_COMMON_LRU_CACHE_H
2 #define AWS_COMMON_LRU_CACHE_H
3 /**
4 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 * SPDX-License-Identifier: Apache-2.0.
6 */
7
8 #include <aws/common/cache.h>
9
10 AWS_PUSH_SANE_WARNING_LEVEL
11 AWS_EXTERN_C_BEGIN
12
13 /**
14 * Initializes the Least-recently-used cache. Sets up the underlying linked hash table.
15 * Once `max_items` elements have been added, the least recently used item will be removed. For the other parameters,
16 * see aws/common/hash_table.h. Hash table semantics of these arguments are preserved.(Yes the one that was the answer
17 * to that interview question that one time).
18 */
19 AWS_COMMON_API
20 struct aws_cache *aws_cache_new_lru(
21 struct aws_allocator *allocator,
22 aws_hash_fn *hash_fn,
23 aws_hash_callback_eq_fn *equals_fn,
24 aws_hash_callback_destroy_fn *destroy_key_fn,
25 aws_hash_callback_destroy_fn *destroy_value_fn,
26 size_t max_items);
27
28 /**
29 * Accesses the least-recently-used element, sets it to most-recently-used
30 * element, and returns the value.
31 */
32 AWS_COMMON_API
33 void *aws_lru_cache_use_lru_element(struct aws_cache *cache);
34
35 /**
36 * Accesses the most-recently-used element and returns its value.
37 */
38 AWS_COMMON_API
39 void *aws_lru_cache_get_mru_element(const struct aws_cache *cache);
40
41 AWS_EXTERN_C_END
42 AWS_POP_SANE_WARNING_LEVEL
43
44 #endif /* AWS_COMMON_LRU_CACHE_H */