30 #define DAPCache3_h_ 1
85 static const char DAP_CACHE_CHAR =
'#';
91 unsigned long long d_max_cache_size_in_bytes;
93 unsigned long long d_target_size;
96 BESCache3(BESKeys *keys,
const string &cache_dir_key,
const string &prefix_key,
const string &size_key);
99 DAPCache3(
const string &cache_dir,
const string &prefix,
unsigned long long size);
106 void m_check_ctor_params();
107 void m_initialize_cache_info();
109 unsigned long long m_collect_cache_dir_info(
CacheFiles &contents);
115 void m_record_descriptor(
const string &file,
int fd);
116 int m_get_descriptor(
const string &file);
119 typedef std::map<string, int> FilesAndLockDescriptors;
120 FilesAndLockDescriptors d_locks;
138 virtual bool cache_too_big(
unsigned long long current_size)
const;
144 static BESCache3 *
get_instance(BESKeys *keys,
const string &cache_dir_key,
const string &prefix_key,
const string &size_key);
146 static DAPCache3 *
get_instance(
const string &cache_dir,
const string &prefix,
unsigned long long size);
149 virtual void dump(ostream &strm)
const ;
152 #endif // DAPCache3_h_
virtual bool get_read_lock(const string &target, int &fd)
Get a read-only lock on the file if it exists.
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.
Implementation of a caching mechanism for compressed data. This cache uses simple advisory locking fo...
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 unsigned long long get_cache_size()
Get the cache size. Read the size information from the cache info file and return it...
static DAPCache3 * get_instance()
virtual unsigned long long update_cache_info(const string &target)
Update the cache info file to include 'target'.
std::list< cache_entry > CacheFiles
virtual void unlock_cache()
virtual bool create_and_lock(const string &target, int &fd)
Create a file in the cache and lock it for write access. If the file does not exist, make it, open it for read-write access and get an exclusive lock on it. The locking operation blocks, although that should never happen.
virtual void unlock_and_close(const string &target)
virtual void lock_cache_read()
virtual void update_and_purge(const string &new_file)
Purge files from the cache.
virtual void exclusive_to_shared_lock(int fd)
Transfer from an exclusive lock to a shared lock. If the file has an exclusive write lock on it...
libdap base object for common functionality of libdap objects
string get_cache_file_name(const string &src, bool mangle=true)
virtual void lock_cache_write()