summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Disco/EntityCapsManager.cpp')
-rw-r--r--Swiften/Disco/EntityCapsManager.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/Swiften/Disco/EntityCapsManager.cpp b/Swiften/Disco/EntityCapsManager.cpp
index 64d90be..28c525f 100644
--- a/Swiften/Disco/EntityCapsManager.cpp
+++ b/Swiften/Disco/EntityCapsManager.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -76,4 +76,20 @@ DiscoInfo::ref EntityCapsManager::getCaps(const JID& jid) const {
return DiscoInfo::ref();
}
+DiscoInfo::ref EntityCapsManager::getCapsCached(const JID& jid) {
+ DiscoInfo::ref result;
+ auto capsHit = caps.find(jid);
+ if (capsHit != caps.end()) {
+ result = lruDiscoCache.get(capsHit->second, [&](const std::string& capsHash) {
+ boost::optional<DiscoInfo::ref> fileCacheResult;
+ auto fileCacheDiscoInfo = capsProvider->getCaps(capsHash);
+ if (fileCacheDiscoInfo) {
+ fileCacheResult = fileCacheDiscoInfo;
+ }
+ return fileCacheResult;
+ }).get_value_or(DiscoInfo::ref());
+ }
+ return result;
+}
+
}