10 #include <arc/DateTime.h> 11 #include <arc/Logger.h> 13 #include "FileCacheHash.h" 23 std::string cache_path;
24 std::string cache_link_path;
64 std::map <std::string, struct CacheParameters> _cache_map;
67 std::vector<struct CacheParameters> _caches;
69 std::vector<struct CacheParameters> _draining_caches;
71 std::vector<struct CacheParameters> _readonly_caches;
74 std::set<std::string> _urls_unlocked;
84 static const std::string CACHE_DATA_DIR;
86 static const std::string CACHE_JOB_DIR;
88 static const int CACHE_DIR_LENGTH;
90 static const int CACHE_DIR_LEVELS;
92 static const std::string CACHE_META_SUFFIX;
94 static const int CACHE_DEFAULT_AUTH_VALIDITY;
97 static const int CACHE_LOCK_TIMEOUT;
99 static const int CACHE_META_LOCK_TIMEOUT;
102 bool _init(
const std::vector<std::string>& caches,
103 const std::vector<std::string>& draining_caches,
104 const std::vector<std::string>& readonly_caches,
105 const std::string&
id,
111 bool _checkMetaFile(
const std::string& filename,
const std::string& url,
bool& is_locked);
114 bool _createMetaFile(
const std::string& meta_file,
const std::string& content,
bool& is_locked);
116 std::string _getMetaFileName(
const std::string& url);
118 std::string _getHash(
const std::string& url)
const;
123 float _getCacheInfo(const std::string& path) const;
125 bool _cleanFilesAndReturnFalse(const std::string& hard_link_file, bool& locked);
146 const std::string& id,
160 FileCache(const std::vector<std::string>& caches,
161 const std::string& id,
179 FileCache(const std::vector<std::string>& caches,
180 const std::vector<std::string>& draining_caches,
181 const std::string& id,
200 FileCache(const std::vector<std::string>& caches,
201 const std::vector<std::string>& draining_caches,
202 const std::vector<std::string>& readonly_caches,
203 const std::string& id,
231 bool Start(
const std::string& url,
234 bool delete_first =
false);
250 bool Stop(
const std::string& url);
271 std::string
File(
const std::string& url);
311 bool Link(
const std::string& link_path,
312 const std::string& url,
336 bool AddDN(
const std::string& url,
const std::string& DN,
const Time& expiry_time);
346 bool CheckDN(
const std::string& url,
const std::string& DN);
367 return (!_caches.empty());
Arc namespace contains all core ARC classes.
Definition: ArcConfig.h:11
bool StopAndDelete(const std::string &url)
Stop the cache after a file was downloaded and delete the cache file.
A class for storing and manipulating times.
Definition: DateTime.h:125
bool CheckDN(const std::string &url, const std::string &DN)
Check if a DN exists in the permission cache and is still valid for the given url.
bool AddDN(const std::string &url, const std::string &DN, const Time &expiry_time)
Store a DN in the permissions cache for the given url.
bool Start(const std::string &url, bool &available, bool &is_locked, bool delete_first=false)
Start preparing to cache the file specified by url.
std::string File(const std::string &url)
Get the cache filename for the given URL.
A logger class.
Definition: Logger.h:493
FileCache provides an interface to all cache operations.
Definition: FileCache.h:61
Contains data on the parameters of a cache.
Definition: FileCache.h:22
Time GetCreated(const std::string &url)
Get the creation time of a cached file.
bool operator==(const FileCache &a)
Returns true if all attributes are equal.
bool CheckCreated(const std::string &url)
Check if it is possible to obtain the creation time of a cache file.
bool Release() const
Release cache files used in this cache.
bool Stop(const std::string &url)
Stop the cache after a file was downloaded.
bool Link(const std::string &link_path, const std::string &url, bool copy, bool executable, bool holding_lock, bool &try_again)
Link a cache file to the place it will be used.