Created
November 10, 2009 01:02
-
-
Save posulliv/230509 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try | |
{ | |
/* check memcached first */ | |
if (isMemcachedUsed()) | |
{ | |
getCache()->get(key, ret_val); | |
if (! ret_val.empty()) | |
{ | |
return true; | |
} | |
} | |
/* ok, we missed in memcache - lets go to S3 */ | |
S3ConnectionPtr s3_ptr= conn_pool->getConnection(); | |
GetResponsePtr get_ptr= s3_ptr->get(bucket_name, key); | |
istream &in_stream= get_ptr->getInputStream(); | |
uint64_t len= get_ptr->getContentLength(); | |
char *buffer= new char[len]; | |
if (in_stream.good()) | |
{ | |
in_stream.read(buffer, len); | |
} | |
ret_val.reserve(len); | |
ret_val.assign(buffer, buffer + len); | |
delete [] buffer; | |
/* now push that value to memcached */ | |
if (isMemcachedUsed()) | |
{ | |
if (! getCache()->set(key, ret_val, 0, 0)) | |
{ | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment