Gets cached entry for the specified key. @param key key @return cached entry or null if the entry is stale
(final byte[] key)
| 27 | * @return cached entry or {@code null} if the entry is stale |
| 28 | */ |
| 29 | public IndexEntry get(final byte[] key) { |
| 30 | final int hash = Token.hashCode(key); |
| 31 | rwl.readLock().lock(); |
| 32 | |
| 33 | try { |
| 34 | final int i = indexFor(hash, buckets.length); |
| 35 | BucketEntry e = buckets[i]; |
| 36 | while(e != null) { |
| 37 | final IndexEntry entry = e.get(); |
| 38 | if(entry != null && e.hash == hash && Token.eq(entry.key, key)) return entry; |
| 39 | e = e.next; |
| 40 | } |
| 41 | } finally { |
| 42 | rwl.readLock().unlock(); |
| 43 | } |
| 44 | return null; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Adds a new cache entry. If an entry with the specified key already exists, |