cache.h revision 299742
1/*
2 * cache.h: cache vtable interface
3 *
4 * ====================================================================
5 *    Licensed to the Apache Software Foundation (ASF) under one
6 *    or more contributor license agreements.  See the NOTICE file
7 *    distributed with this work for additional information
8 *    regarding copyright ownership.  The ASF licenses this file
9 *    to you under the Apache License, Version 2.0 (the
10 *    "License"); you may not use this file except in compliance
11 *    with the License.  You may obtain a copy of the License at
12 *
13 *      http://www.apache.org/licenses/LICENSE-2.0
14 *
15 *    Unless required by applicable law or agreed to in writing,
16 *    software distributed under the License is distributed on an
17 *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 *    KIND, either express or implied.  See the License for the
19 *    specific language governing permissions and limitations
20 *    under the License.
21 * ====================================================================
22 */
23
24#ifndef SVN_LIBSVN_SUBR_CACHE_H
25#define SVN_LIBSVN_SUBR_CACHE_H
26
27#include "private/svn_cache.h"
28
29#ifdef __cplusplus
30extern "C" {
31#endif /* __cplusplus */
32
33typedef struct svn_cache__vtable_t {
34  /* See svn_cache__get(). */
35  svn_error_t *(*get)(void **value,
36                      svn_boolean_t *found,
37                      void *cache_implementation,
38                      const void *key,
39                      apr_pool_t *result_pool);
40
41  /* See svn_cache__has_key(). */
42  svn_error_t *(*has_key)(svn_boolean_t *found,
43                          void *cache_implementation,
44                          const void *key,
45                          apr_pool_t *scratch_pool);
46
47  /* See svn_cache__set(). */
48  svn_error_t *(*set)(void *cache_implementation,
49                      const void *key,
50                      void *value,
51                      apr_pool_t *scratch_pool);
52
53  /* See svn_cache__iter(). */
54  svn_error_t *(*iter)(svn_boolean_t *completed,
55                       void *cache_implementation,
56                       svn_iter_apr_hash_cb_t func,
57                       void *baton,
58                       apr_pool_t *scratch_pool);
59
60  /* See svn_cache__is_cachable(). */
61  svn_boolean_t (*is_cachable)(void *cache_implementation,
62                               apr_size_t size);
63
64  /* See svn_cache__get_partial(). */
65  svn_error_t *(*get_partial)(void **value,
66                              svn_boolean_t *found,
67                              void *cache_implementation,
68                              const void *key,
69                              svn_cache__partial_getter_func_t func,
70                              void *baton,
71                              apr_pool_t *result_pool);
72
73  /* See svn_cache__set_partial(). */
74  svn_error_t *(*set_partial)(void *cache_implementation,
75                              const void *key,
76                              svn_cache__partial_setter_func_t func,
77                              void *baton,
78                              apr_pool_t *scratch_pool);
79
80  /* See svn_cache__get_info(). */
81  svn_error_t *(*get_info)(void *cache_implementation,
82                           svn_cache__info_t *info,
83                           svn_boolean_t reset,
84                           apr_pool_t *result_pool);
85} svn_cache__vtable_t;
86
87struct svn_cache__t {
88  const svn_cache__vtable_t *vtable;
89
90  /* See svn_cache__set_error_handler(). */
91  svn_cache__error_handler_t error_handler;
92  void *error_baton;
93
94  /* Private data for the cache implementation. */
95  void *cache_internal;
96
97  /* Total number of calls to getters. */
98  apr_uint64_t reads;
99
100  /* Total number of calls to set(). */
101  apr_uint64_t writes;
102
103  /* Total number of getter calls that returned a cached item. */
104  apr_uint64_t hits;
105
106  /* Total number of function calls that returned an error. */
107  apr_uint64_t failures;
108
109  /* Cause all getters to act as though the cache contains no data.
110     (Currently this never becomes set except in maintainer builds.) */
111  svn_boolean_t pretend_empty;
112};
113
114
115#ifdef __cplusplus
116}
117#endif /* __cplusplus */
118
119#endif /* SVN_LIBSVN_SUBR_CACHE_H */
120