81 bool use_default =
true;
83 if ( ! dir.empty() ) {
99 char *env = getenv(
"OM_CACHE_PATH" );
103 string om_cache_path = (
char const *)env;
105 if ( ! om_cache_path.empty() ) {
107 Log::instance()->
debug(
"Using cache directory defined in OM_CACHE_PATH: %s\n", om_cache_path.c_str() );
152 if ( ! subdir.empty() ) {
163 ifstream ifile(path.c_str(), std::ios::in);
192 if ( ! subdir.empty() ) {
203 ofstream ofile( path.c_str() );
207 ofile << content.str();
235 if ( ! subdir.empty() ) {
260 const size_t MYSIZE = 16;
262 unsigned char digest[MYSIZE];
266 MD5_Update( &md5, const_cast<char *>(
id.c_str() ),
id.size() );
269 char buffer[(MYSIZE*2)+1];
271 for (
unsigned int i = 0; i < MYSIZE; ++i ) {
273 sprintf(&buffer[i*2],
"%02x", (
unsigned int)digest[i]);
276 std::string md5_id( buffer );
289 return remove(path.c_str());
void MD5_Final(unsigned char *result, MD5_CTX *ctx)
static std::string getContentIdMd5(const std::string id)
static bool isCached(const std::string id, const std::string subdir="")
static void cache(const std::string id, const std::ostringstream &content, const std::string subdir="")
static void cacheMd5(const std::string id, const std::ostringstream &content, const std::string subdir="")
bool createPath(const std::string path)
static Log * instance()
Returns the instance pointer, creating the object on the first call.
static std::string getContentLocation(const std::string id, const std::string subdir="")
static void initialize(const std::string dir="")
static std::string get(const std::string &key)
static int eraseCache(const std::string id, const std::string subdir="")
void error(const char *format,...)
'Error' level.
std::string getWorkingPath()
static bool isCachedMd5(const std::string id, const std::string subdir="")
bool pathExists(const std::string path)
void MD5_Update(MD5_CTX *ctx, void *data, unsigned long size)
static void _ensureInitialized()
void MD5_Init(MD5_CTX *ctx)
static int count(const std::string &key)
static CacheManager & _getInstance()
static std::string getContentLocationMd5(const std::string id, const std::string subdir="")
static int eraseCacheMd5(const std::string id, const std::string subdir="")
void debug(const char *format,...)
'Debug' level.