void StorageAccess::accessCache(QString const & pCacheString, CacheMissCallback && pMiss, DataCallback && pHit) { QByteArray lData; if (fromCache(pCacheString, lData)) { pHit(lData); } else { pMiss([this, pCacheString, CAPTURE(pHit)] (QByteArray const& pData) { insertInCache(pCacheString, pData); pHit(pData); }); } }
int CacheSyncSource::addItem(SyncItem& item) { int ret = insertItem(item); switch (ret) { case 200: case 201: case 418: { LOG.info("[%s] Successful add of item with key %s - code %d", getName(), item.getKey(), ret); KeyValuePair k; getKeyAndSignature(item, k); insertInCache(k); } break; default: LOG.error("[%s] Failed add of item with key %s - code %d", getName(), item.getKey(), ret); break; } return ret; }