Skip to content

Commit

Permalink
added new options to image cache
Browse files Browse the repository at this point in the history
  • Loading branch information
fnc12 committed Jan 27, 2018
1 parent 22e447f commit ff5ac02
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ImageCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,16 @@ void Mitsoko::ImageCache::Callback::disposableDidDispose(Disposable::Id id){

void Mitsoko::ImageCache::get(const std::string &url, Callback cb){
std::string key, filepath;
if(auto res = getCached(url, &key, &filepath)){
auto res = getCached(url, &key, &filepath);
if(res && !this->neverRestoresCachedImages){
cb(res);
}else{
auto it = this->callbacks.find(url);
if(it == this->callbacks.end()){
callbacks[url].push_back(cb);
Url::Request request;
request.url(url);
request.performAsync<Image>([=](Url::Response response, Mitsoko::Image image, Url::Error error) {
request.performAsync<Image>([=](Url::Response response, Image image, Url::Error error) {
(void)response;
(void)error;
if(image) {
Expand Down
2 changes: 2 additions & 0 deletions ImageCache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ namespace Mitsoko {

bool usesRamCache = true;

bool neverRestoresCachedImages = false;

protected:
std::map<std::string, std::vector<Callback>> callbacks;

Expand Down

0 comments on commit ff5ac02

Please sign in to comment.