BESCache.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef BESCache_h_
00034 #define BESCache_h_ 1
00035
00036 #include <string>
00037
00038 using std::string ;
00039
00040 #include "BESObj.h"
00041
00042 class BESKeys ;
00043
00044 #define MAX_LOCK_RETRY_MS 5000 // in microseconds
00045 #define MAX_LOCK_TRIES 16
00046
00057 class BESCache : public BESObj
00058 {
00059 private:
00060 string _cache_dir ;
00061 string _prefix ;
00062 unsigned int _cache_size ;
00063 int _lock_fd ;
00064
00065 void check_ctor_params();
00066 BESCache() {}
00067 public:
00068 BESCache( const string &cache_dir,
00069 const string &prefix,
00070 unsigned int size ) ;
00071 BESCache( BESKeys &keys,
00072 const string &cache_dir_key,
00073 const string &prefix_key,
00074 const string &size_key ) ;
00075 virtual ~BESCache() {}
00076
00077 virtual bool lock( unsigned int retry_ms,
00078 unsigned int num_tries ) ;
00079 virtual bool unlock() ;
00080
00081 virtual bool is_cached( const string &src, string &target ) ;
00082 virtual void purge( ) ;
00083
00084 string cache_dir( ) { return _cache_dir ; }
00085 string prefix( ) { return _prefix ; }
00086 unsigned int cache_size( ) { return _cache_size ; }
00087
00088 virtual void dump( ostream &strm ) const ;
00089 };
00090
00091 #endif // BESCache_h_
00092