cjcchen commented on code in PR #170:
URL:
https://github.com/apache/incubator-resilientdb/pull/170#discussion_r1954302894
##########
common/lru/lru_cache.cpp:
##########
@@ -0,0 +1,101 @@
+#include "lru_cache.h"
+
+#include <algorithm>
+
+namespace resdb {
+
+template <typename KeyType, typename ValueType>
+LRUCache<KeyType, ValueType>::LRUCache(int capacity) {
+ m_ = capacity;
+ cache_hits_ = 0;
+ cache_misses_ = 0;
+}
+
+template <typename KeyType, typename ValueType>
+LRUCache<KeyType, ValueType>::~LRUCache() {
+ um_.clear();
+ dq_.clear();
+}
+
+template <typename KeyType, typename ValueType>
+ValueType LRUCache<KeyType, ValueType>::Get(KeyType key) {
+ if (!um_.count(key)) {
+ cache_misses_++;
+ return ValueType();
+ }
+
+ auto it = std::find(dq_.begin(), dq_.end(), key);
Review Comment:
performance issue?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]