29 #ifndef BESFileLockingCache_h_
30 #define BESFileLockingCache_h_ 1
42 unsigned long long size;
75 static const char DAP_CACHE_CHAR =
'#';
81 unsigned long long d_max_cache_size_in_bytes;
83 unsigned long long d_target_size;
90 void m_check_ctor_params();
91 void m_initialize_cache_info();
93 unsigned long long m_collect_cache_dir_info(
CacheFiles &contents);
99 void m_record_descriptor(
const string &file,
int fd);
100 int m_get_descriptor(
const string &file);
103 typedef std::multimap<string, int> FilesAndLockDescriptors;
104 FilesAndLockDescriptors d_locks;
109 BESFileLockingCache(): d_cache_dir(
""), d_prefix(
""), d_max_cache_size_in_bytes(0), d_target_size(0), d_cache_info(
""), d_cache_info_fd(0){};
110 void initialize(
const string &cache_dir,
const string &prefix,
unsigned long long size);
111 BESFileLockingCache(
const string &cache_dir,
const string &prefix,
unsigned long long size);
129 virtual bool cache_too_big(
unsigned long long current_size)
const;
137 virtual void dump(ostream &strm)
const ;
140 #endif // BESFileLockingCache_h_
virtual void unlock_cache()
Unlock the cache info file.
std::list< cache_entry > CacheFiles
virtual bool create_and_lock(const string &target, int &fd)
Create a file in the cache and lock it for write access.
const string getCacheDirectory()
virtual unsigned long long get_cache_size()
Get the cache size.
Implementation of a caching mechanism for compressed data.
Base object for bes objects.
void initialize(const string &cache_dir, const string &prefix, unsigned long long size)
virtual void dump(ostream &strm) const
dumps information about this object
virtual void purge_file(const string &file)
Purge a single file from the cache.
std::list< cache_entry > CacheFiles
virtual bool cache_too_big(unsigned long long current_size) const
look at the cache size; is it too large? Look at the cache size and see if it is too big...
virtual void lock_cache_write()
Get an exclusive lock on the 'cache info' file.
virtual string get_cache_file_name(const string &src, bool mangle=true)
Build the name of file that will holds the uncompressed data from 'src' in the cache.
const string getCacheFilePrefix()
virtual bool get_read_lock(const string &target, int &fd)
Get a read-only lock on the file if it exists.
virtual void update_and_purge(const string &new_file)
Purge files from the cache.
virtual unsigned long long update_cache_info(const string &target)
Update the cache info file to include 'target'.
virtual void lock_cache_read()
Get a shared lock on the 'cache info' file.
virtual void exclusive_to_shared_lock(int fd)
Transfer from an exclusive lock to a shared lock.
virtual ~BESFileLockingCache()
virtual void unlock_and_close(const string &target)
Unlock the named file.