com.thimbleware.jmemcached.storage.bytebuffer
Class BlockStorageCacheStorage
java.lang.Object
com.thimbleware.jmemcached.storage.bytebuffer.BlockStorageCacheStorage
- All Implemented Interfaces:
- CacheStorage<Key,LocalCacheElement>, java.util.concurrent.ConcurrentMap<Key,LocalCacheElement>, java.util.Map<Key,LocalCacheElement>
public final class BlockStorageCacheStorage
- extends java.lang.Object
- implements CacheStorage<Key,LocalCacheElement>
Implementation of the concurrent (linked) sized map using the block buffer storage back end.
TODO Rather sub-optimal global locking strategy could be improved with a more intricate :dstriped locking implementation.
| Nested classes/interfaces inherited from interface java.util.Map |
java.util.Map.Entry<K,V> |
|
Method Summary |
int |
capacity()
|
void |
clear()
|
void |
close()
Close the storage unit, deallocating any resources it might be currently holding. |
boolean |
containsKey(java.lang.Object o)
|
boolean |
containsValue(java.lang.Object o)
|
java.util.Set<java.util.Map.Entry<Key,LocalCacheElement>> |
entrySet()
|
LocalCacheElement |
get(java.lang.Object key)
|
long |
getMemoryCapacity()
|
long |
getMemoryUsed()
|
boolean |
isEmpty()
|
java.util.Set<Key> |
keySet()
|
void |
lockRead(com.thimbleware.jmemcached.storage.bytebuffer.BlockStorageCacheStorage.StoredValue value)
|
void |
lockReadAll()
|
void |
lockWrite(com.thimbleware.jmemcached.storage.bytebuffer.BlockStorageCacheStorage.StoredValue value)
|
void |
lockWriteAll()
|
static int |
numBuckets(int size,
int bucketSize)
|
LocalCacheElement |
put(Key key,
LocalCacheElement item)
|
void |
putAll(java.util.Map<? extends Key,? extends LocalCacheElement> map)
|
LocalCacheElement |
putIfAbsent(Key key,
LocalCacheElement item)
|
LocalCacheElement |
remove(java.lang.Object key)
|
boolean |
remove(java.lang.Object key,
java.lang.Object value)
|
LocalCacheElement |
replace(Key key,
LocalCacheElement replace)
|
boolean |
replace(Key key,
LocalCacheElement original,
LocalCacheElement replace)
|
int |
size()
|
void |
unlockRead(com.thimbleware.jmemcached.storage.bytebuffer.BlockStorageCacheStorage.StoredValue value)
|
void |
unlockReadAll()
|
void |
unlockWrite(com.thimbleware.jmemcached.storage.bytebuffer.BlockStorageCacheStorage.StoredValue value)
|
void |
unlockWriteAll()
|
java.util.Collection<LocalCacheElement> |
values()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Map |
equals, hashCode |
BlockStorageCacheStorage
public BlockStorageCacheStorage(int blockStoreBuckets,
int ceilingBytesParam,
int blockSizeBytes,
long maximumSizeBytes,
int maximumItemsVal,
BlockStoreFactory factory)
getMemoryCapacity
public final long getMemoryCapacity()
- Specified by:
getMemoryCapacity in interface CacheStorage<Key,LocalCacheElement>
- Returns:
- the capacity (in bytes) of the storage
getMemoryUsed
public final long getMemoryUsed()
- Specified by:
getMemoryUsed in interface CacheStorage<Key,LocalCacheElement>
- Returns:
- the current usage (in bytes) of the storage
capacity
public final int capacity()
- Specified by:
capacity in interface CacheStorage<Key,LocalCacheElement>
- Returns:
- the capacity (in # of items) of the storage
close
public final void close()
throws java.io.IOException
- Description copied from interface:
CacheStorage
- Close the storage unit, deallocating any resources it might be currently holding.
- Specified by:
close in interface CacheStorage<Key,LocalCacheElement>
- Throws:
java.io.IOException - thrown if IO faults occur anywhere during close.
putIfAbsent
public final LocalCacheElement putIfAbsent(Key key,
LocalCacheElement item)
- Specified by:
putIfAbsent in interface java.util.concurrent.ConcurrentMap<Key,LocalCacheElement>
remove
public final boolean remove(java.lang.Object key,
java.lang.Object value)
-
- Specified by:
remove in interface java.util.concurrent.ConcurrentMap<Key,LocalCacheElement>
replace
public final boolean replace(Key key,
LocalCacheElement original,
LocalCacheElement replace)
- Specified by:
replace in interface java.util.concurrent.ConcurrentMap<Key,LocalCacheElement>
replace
public final LocalCacheElement replace(Key key,
LocalCacheElement replace)
- Specified by:
replace in interface java.util.concurrent.ConcurrentMap<Key,LocalCacheElement>
size
public final int size()
- Specified by:
size in interface java.util.Map<Key,LocalCacheElement>
isEmpty
public final boolean isEmpty()
- Specified by:
isEmpty in interface java.util.Map<Key,LocalCacheElement>
containsKey
public final boolean containsKey(java.lang.Object o)
- Specified by:
containsKey in interface java.util.Map<Key,LocalCacheElement>
containsValue
public final boolean containsValue(java.lang.Object o)
- Specified by:
containsValue in interface java.util.Map<Key,LocalCacheElement>
get
public final LocalCacheElement get(java.lang.Object key)
- Specified by:
get in interface java.util.Map<Key,LocalCacheElement>
numBuckets
public static int numBuckets(int size,
int bucketSize)
put
public final LocalCacheElement put(Key key,
LocalCacheElement item)
- Specified by:
put in interface java.util.Map<Key,LocalCacheElement>
remove
public final LocalCacheElement remove(java.lang.Object key)
- Specified by:
remove in interface java.util.Map<Key,LocalCacheElement>
putAll
public final void putAll(java.util.Map<? extends Key,? extends LocalCacheElement> map)
- Specified by:
putAll in interface java.util.Map<Key,LocalCacheElement>
clear
public final void clear()
- Specified by:
clear in interface java.util.Map<Key,LocalCacheElement>
lockReadAll
public void lockReadAll()
unlockReadAll
public void unlockReadAll()
lockWriteAll
public void lockWriteAll()
unlockWriteAll
public void unlockWriteAll()
lockRead
public void lockRead(com.thimbleware.jmemcached.storage.bytebuffer.BlockStorageCacheStorage.StoredValue value)
unlockRead
public void unlockRead(com.thimbleware.jmemcached.storage.bytebuffer.BlockStorageCacheStorage.StoredValue value)
lockWrite
public void lockWrite(com.thimbleware.jmemcached.storage.bytebuffer.BlockStorageCacheStorage.StoredValue value)
unlockWrite
public void unlockWrite(com.thimbleware.jmemcached.storage.bytebuffer.BlockStorageCacheStorage.StoredValue value)
keySet
public java.util.Set<Key> keySet()
- Specified by:
keySet in interface java.util.Map<Key,LocalCacheElement>
values
public java.util.Collection<LocalCacheElement> values()
- Specified by:
values in interface java.util.Map<Key,LocalCacheElement>
entrySet
public java.util.Set<java.util.Map.Entry<Key,LocalCacheElement>> entrySet()
- Specified by:
entrySet in interface java.util.Map<Key,LocalCacheElement>
Copyright © 2008-2011 ThimbleWare. All Rights Reserved.