1251881Speter/* rep-cache.h : interface to rep cache db functions
2251881Speter *
3251881Speter * ====================================================================
4251881Speter *    Licensed to the Apache Software Foundation (ASF) under one
5251881Speter *    or more contributor license agreements.  See the NOTICE file
6251881Speter *    distributed with this work for additional information
7251881Speter *    regarding copyright ownership.  The ASF licenses this file
8251881Speter *    to you under the Apache License, Version 2.0 (the
9251881Speter *    "License"); you may not use this file except in compliance
10251881Speter *    with the License.  You may obtain a copy of the License at
11251881Speter *
12251881Speter *      http://www.apache.org/licenses/LICENSE-2.0
13251881Speter *
14251881Speter *    Unless required by applicable law or agreed to in writing,
15251881Speter *    software distributed under the License is distributed on an
16251881Speter *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17251881Speter *    KIND, either express or implied.  See the License for the
18251881Speter *    specific language governing permissions and limitations
19251881Speter *    under the License.
20251881Speter * ====================================================================
21251881Speter */
22251881Speter
23251881Speter#ifndef SVN_LIBSVN_FS_FS_REP_CACHE_H
24251881Speter#define SVN_LIBSVN_FS_FS_REP_CACHE_H
25251881Speter
26251881Speter#include "svn_error.h"
27251881Speter
28251881Speter#include "fs.h"
29251881Speter
30251881Speter#ifdef __cplusplus
31251881Speterextern "C" {
32251881Speter#endif /* __cplusplus */
33251881Speter
34251881Speter
35251881Speter#define REP_CACHE_DB_NAME        "rep-cache.db"
36251881Speter
37251881Speter/* Open and create, if needed, the rep cache database associated with FS.
38251881Speter   Use POOL for temporary allocations. */
39251881Spetersvn_error_t *
40251881Spetersvn_fs_fs__open_rep_cache(svn_fs_t *fs,
41251881Speter                          apr_pool_t *pool);
42251881Speter
43251881Speter/* Set *EXISTS to TRUE iff the rep-cache DB file exists. */
44251881Spetersvn_error_t *
45251881Spetersvn_fs_fs__exists_rep_cache(svn_boolean_t *exists,
46251881Speter                            svn_fs_t *fs, apr_pool_t *pool);
47251881Speter
48251881Speter/* Iterate all representations currently in FS's cache. */
49251881Spetersvn_error_t *
50251881Spetersvn_fs_fs__walk_rep_reference(svn_fs_t *fs,
51251881Speter                              svn_revnum_t start,
52251881Speter                              svn_revnum_t end,
53251881Speter                              svn_error_t *(*walker)(representation_t *rep,
54251881Speter                                                     void *walker_baton,
55251881Speter                                                     svn_fs_t *fs,
56251881Speter                                                     apr_pool_t *scratch_pool),
57251881Speter                              void *walker_baton,
58251881Speter                              svn_cancel_func_t cancel_func,
59251881Speter                              void *cancel_baton,
60251881Speter                              apr_pool_t *pool);
61251881Speter
62251881Speter/* Return the representation REP in FS which has fulltext CHECKSUM.
63251881Speter   REP is allocated in POOL.  If the rep cache database has not been
64289180Speter   opened, just set *REP to NULL.  Returns SVN_ERR_FS_CORRUPT if
65289180Speter   a reference beyond HEAD is detected. */
66251881Spetersvn_error_t *
67251881Spetersvn_fs_fs__get_rep_reference(representation_t **rep,
68251881Speter                             svn_fs_t *fs,
69251881Speter                             svn_checksum_t *checksum,
70251881Speter                             apr_pool_t *pool);
71251881Speter
72251881Speter/* Set the representation REP in FS, using REP->CHECKSUM.
73289180Speter   Use POOL for temporary allocations.  Returns SVN_ERR_FS_CORRUPT if
74289180Speter   an existing reference beyond HEAD is detected.
75251881Speter
76289180Speter   If the rep cache database has not been opened, this may be a no op. */
77251881Spetersvn_error_t *
78251881Spetersvn_fs_fs__set_rep_reference(svn_fs_t *fs,
79251881Speter                             representation_t *rep,
80251881Speter                             apr_pool_t *pool);
81251881Speter
82251881Speter/* Delete from the cache all reps corresponding to revisions younger
83251881Speter   than YOUNGEST. */
84251881Spetersvn_error_t *
85251881Spetersvn_fs_fs__del_rep_reference(svn_fs_t *fs,
86251881Speter                             svn_revnum_t youngest,
87251881Speter                             apr_pool_t *pool);
88251881Speter
89251881Speter/* Start a transaction to take an SQLite reserved lock that prevents
90289180Speter   other writes, call BODY, end the transaction, and return what BODY returned.
91289180Speter */
92251881Spetersvn_error_t *
93289180Spetersvn_fs_fs__with_rep_cache_lock(svn_fs_t *fs,
94289180Speter                               svn_error_t *(*body)(void *baton,
95289180Speter                                                    apr_pool_t *pool),
96289180Speter                               void *baton,
97289180Speter                               apr_pool_t *pool);
98251881Speter
99251881Speter#ifdef __cplusplus
100251881Speter}
101251881Speter#endif /* __cplusplus */
102251881Speter
103251881Speter#endif /* SVN_LIBSVN_FS_FS_REP_CACHE_H */
104