2 * Copyright (c) 2022 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #ifndef SRC_PLUGINS_HTTP_STATIC_HTTP_CACHE_H_
17 #define SRC_PLUGINS_HTTP_STATIC_HTTP_CACHE_H_
19 #include <vppinfra/bihash_vec8_8.h>
21 typedef struct hss_cache_entry_
23 /** Name of the file */
25 /** Contents of the file, as a u8 * vector */
27 /** Last time the cache entry was used */
29 /** Cache LRU links */
32 /** Reference count, so we don't recycle while referenced */
36 typedef struct hss_cache_
38 /** Unified file data cache pool */
39 hss_cache_entry_t *cache_pool;
40 /** Hash table which maps file name to file data */
41 BVT (clib_bihash) name_to_data;
43 /** Session pool lock */
44 clib_spinlock_t cache_lock;
46 /** Current cache size */
48 /** Max cache size in bytes */
50 /** Number of cache evictions */
53 /** Cache LRU listheads */
60 u32 hss_cache_lookup_and_attach (hss_cache_t *hc, u8 *path, u8 **data,
62 u32 hss_cache_add_and_attach (hss_cache_t *hc, u8 *path, u8 **data,
64 void hss_cache_detach_entry (hss_cache_t *hc, u32 ce_index);
65 u32 hss_cache_clear (hss_cache_t *hc);
66 void hss_cache_init (hss_cache_t *hc, uword cache_size, u8 debug_level);
68 u8 *format_hss_cache (u8 *s, va_list *args);
70 #endif /* SRC_PLUGINS_HTTP_STATIC_HTTP_CACHE_H_ */
73 * fd.io coding-style-patch-verification: ON
76 * eval: (c-set-style "gnu")