-
Notifications
You must be signed in to change notification settings - Fork 771
/
Copy pathCacheUtil.hpp
56 lines (44 loc) · 1.48 KB
/
CacheUtil.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* Copyright the Collabora Online contributors.
*
* SPDX-License-Identifier: MPL-2.0
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <cstddef>
#include <cstdint>
#include <mutex>
#include <string>
#include <unordered_map>
#include <vector>
struct CacheQuery
{
std::string _uri;
std::string _stamp;
std::string _dest;
CacheQuery(const std::string& uri, const std::string& stamp, const std::string& dest)
: _uri(uri)
, _stamp(stamp)
, _dest(dest)
{
}
};
class Cache
{
public:
static void initialize(const std::string& path);
static std::string getConfigId(const std::string& uri);
static void cacheConfigFile(const std::string& configId, const std::string& uri,
const std::string& stamp, const std::string& filename);
static void supplyConfigFiles(const std::string& configId, std::vector<CacheQuery>& queries);
static void clearOutdatedConfigs();
private:
static void updateLastUsed(const std::string& path);
static bool supplyConfigFile(const std::string& cacheDir, const std::string& stamp,
const std::string& dest);
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */