Package ubic.gemma.persistence.cache
Class StaticCacheKeyLock
- java.lang.Object
-
- ubic.gemma.persistence.cache.StaticCacheKeyLock
-
- All Implemented Interfaces:
CacheKeyLock
public class StaticCacheKeyLock extends Object implements CacheKeyLock
Implementation of theCacheKeyLock
interface that uses a static week map to store locks by key.Locks are guaranteed to be kept around as long as there is a
CacheKeyLock.LockAcquisition
referring to it, otherwise they might be freed by the GC.- Author:
- poirigui
- See Also:
WeakHashMap
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface ubic.gemma.persistence.cache.CacheKeyLock
CacheKeyLock.LockAcquisition
-
-
Constructor Summary
Constructors Constructor Description StaticCacheKeyLock(org.springframework.cache.Cache cache, Object key, boolean readOnly)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isReadOnly()
Indicate if this lock is read-only.CacheKeyLock.LockAcquisition
lock()
Acquire a lock on the cache key.CacheKeyLock.LockAcquisition
lockInterruptibly()
Acquire a lock interruptibly on a cache key.
-
-
-
Constructor Detail
-
StaticCacheKeyLock
public StaticCacheKeyLock(org.springframework.cache.Cache cache, Object key, boolean readOnly)
-
-
Method Detail
-
isReadOnly
public boolean isReadOnly()
Description copied from interface:CacheKeyLock
Indicate if this lock is read-only.- Specified by:
isReadOnly
in interfaceCacheKeyLock
-
lock
public CacheKeyLock.LockAcquisition lock()
Description copied from interface:CacheKeyLock
Acquire a lock on the cache key.- Specified by:
lock
in interfaceCacheKeyLock
-
lockInterruptibly
public CacheKeyLock.LockAcquisition lockInterruptibly() throws InterruptedException
Description copied from interface:CacheKeyLock
Acquire a lock interruptibly on a cache key.- Specified by:
lockInterruptibly
in interfaceCacheKeyLock
- Throws:
InterruptedException
- if the current thread was interrupted prior to or while waiting on the lock
-
-