Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1230)

Unified Diff: pkg/analysis_server/lib/src/index/lru_cache.dart

Issue 329633002: Some clean ups for caching tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/index/page_node_manager.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/index/lru_cache.dart
diff --git a/pkg/analysis_server/lib/src/index/lru_cache.dart b/pkg/analysis_server/lib/src/index/lru_cache.dart
index 38d2fa718017848dcf1c9848b474dcc1ac0d59d5..82dfeb54c53ef28cc42a19b60b156565a504771a 100644
--- a/pkg/analysis_server/lib/src/index/lru_cache.dart
+++ b/pkg/analysis_server/lib/src/index/lru_cache.dart
@@ -16,7 +16,7 @@ typedef EvictionHandler<K, V>(K key, V value);
* A hash-table based cache implementation.
*
* When it reaches the specified number of items, the item that has not been
- * accessed recently is evicted.
+ * accessed (both get and put) recently is evicted.
*/
class LRUCache<K, V> {
final LinkedHashSet<K> _lastKeys = new LinkedHashSet<K>();
@@ -54,6 +54,7 @@ class LRUCache<K, V> {
* evicted.
*/
void put(K key, V value) {
+ _lastKeys.remove(key);
_lastKeys.add(key);
if (_lastKeys.length > _maxSize) {
K evictedKey = _lastKeys.first;
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/index/page_node_manager.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698