-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
10 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,15 +9,15 @@ | |
import java.util.concurrent.locks.ReentrantLock; | ||
|
||
/** | ||
* This class provides a thread-safe Least Recently Used (LRU) cache API that will evict the least recently used items, | ||
* This class provides a thread-safe Least Recently Used (LRU) cache API that evicts the least recently used items | ||
* once a threshold is met. It implements the <code>Map</code> interface for convenience. | ||
* <p> | ||
* The Locking strategy allows for O(1) access for get(), put(), and remove(). For put(), remove(), and many other | ||
* methods, a write-lock is obtained. For get(), it attempts to lock but does not lock unless it can obtain it right away. | ||
* This 'try-lock' approach ensures that the get() API is never blocking, but it also means that the LRU order is not | ||
* perfectly maintained under heavy load. | ||
* <p> | ||
* LRUCache supports <code>null</code> for both key or value. | ||
* LRUCache supports <code>null</code> for both key and value. | ||
* @author John DeRegnaucourt ([email protected]) | ||
* <br> | ||
* Copyright (c) Cedar Software LLC | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,15 +16,15 @@ | |
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
/** | ||
* This class provides a thread-safe Least Recently Used (LRU) cache API that will evict the least recently used items, | ||
* This class provides a thread-safe Least Recently Used (LRU) cache API that evicts the least recently used items | ||
* once a threshold is met. It implements the <code>Map</code> interface for convenience. | ||
* <p> | ||
* The Threaded strategy allows for O(1) access for get(), put(), and remove() without blocking. It uses a <code>ConcurrentHashMap</code> | ||
* internally. To ensure that the capacity is honored, whenever put() is called, a thread (from a thread pool) is tasked | ||
* with cleaning up items above the capacity threshold. This means that the cache may temporarily exceed its capacity, but | ||
* it will soon be trimmed back to the capacity limit by the scheduled thread. | ||
* <p> | ||
* LRUCache supports <code>null</code> for both key or value. | ||
* LRUCache supports <code>null</code> for both key and value. | ||
* <p> | ||
* @author John DeRegnaucourt ([email protected]) | ||
* <br> | ||
|