30 #define DAPCache3_h_ 1 53 unsigned long long size;
57 typedef std::list<cache_entry> CacheFiles;
87 static const char DAP_CACHE_CHAR =
'#';
93 unsigned long long d_max_cache_size_in_bytes;
95 unsigned long long d_target_size;
98 BESCache3(BESKeys *keys,
const string &cache_dir_key,
const string &prefix_key,
const string &size_key);
101 DAPCache3(
const string &cache_dir,
const string &prefix,
unsigned long long size);
108 void m_check_ctor_params();
109 void m_initialize_cache_info();
111 unsigned long long m_collect_cache_dir_info(CacheFiles &contents);
117 void m_record_descriptor(
const string &file,
int fd);
118 int m_get_descriptor(
const string &file);
121 typedef std::map<string, int> FilesAndLockDescriptors;
122 FilesAndLockDescriptors d_locks;
126 static void delete_instance();
129 static DAPCache3 *
get_instance(
const string &cache_dir,
const string &prefix,
unsigned long long size);
138 virtual void unlock_and_close(
const string &target);
139 virtual void unlock_and_close(
int fd);
146 virtual bool cache_too_big(
unsigned long long current_size)
const;
152 static BESCache3 *
get_instance(BESKeys *keys,
const string &cache_dir_key,
const string &prefix_key,
const string &size_key);
155 virtual void dump(ostream &strm)
const ;
160 #endif // DAPCache3_h_ virtual unsigned long long update_cache_info(const string &target)
Update the cache info file to include 'target'.
string get_cache_file_name(const string &src, bool mangle=true)
virtual void dump(ostream &strm) const
dumps information about this object
virtual unsigned long long get_cache_size()
Get the cache size. Read the size information from the cache info file and return it...
top level DAP object to house generic methods
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 lock_cache_write()
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 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...
virtual bool get_read_lock(const string &target, int &fd)
Get a read-only lock on the file if it exists.
virtual void lock_cache_read()
virtual void update_and_purge(const string &new_file)
Purge files from the cache.
libdap base object for common functionality of libdap objects
static DAPCache3 * get_instance()
Implementation of a caching mechanism for compressed data. This cache uses simple advisory locking fo...
virtual void purge_file(const string &file)
Purge a single file from the cache.
virtual void unlock_cache()