本文整理了Java中net.sf.ehcache.Cache.getLockForKey()
方法的一些代码示例,展示了Cache.getLockForKey()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cache.getLockForKey()
方法的具体详情如下:
包路径:net.sf.ehcache.Cache
类名称:Cache
方法名:getLockForKey
[英]Gets the lock for a given key
[中]获取给定密钥的锁
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* {@inheritDoc}
* <p>
* Only Terracotta clustered cache instances currently support querying a thread's read lock hold status.
*/
public boolean isReadLockedByCurrentThread(Object key) throws UnsupportedOperationException {
return getLockForKey(key).isHeldByCurrentThread(LockType.READ);
}
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* {@inheritDoc}
*/
public boolean isWriteLockedByCurrentThread(Object key) {
return getLockForKey(key).isHeldByCurrentThread(LockType.WRITE);
}
代码示例来源:origin: net.sf.ehcache/ehcache
private void acquireLockOnKey(Object key, LockType lockType) {
Sync s = getLockForKey(key);
s.lock(lockType);
}
代码示例来源:origin: net.sf.ehcache/ehcache
private void releaseLockOnKey(Object key, LockType lockType) {
Sync s = getLockForKey(key);
s.unlock(lockType);
}
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* Try to get a read lock on a given key. If can't get it in timeout millis then
* return a boolean telling that it didn't get the lock
*
* @param key - The key that retrieves a value that you want to protect via locking
* @param timeout - millis until giveup on getting the lock
* @return whether the lock was awarded
* @throws InterruptedException in case the thread was interrupted
*/
public boolean tryReadLockOnKey(Object key, long timeout) throws InterruptedException {
Sync s = getLockForKey(key);
return s.tryLock(LockType.READ, timeout);
}
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* Try to get a write lock on a given key. If can't get it in timeout millis then
* return a boolean telling that it didn't get the lock
*
* @param key - The key that retrieves a value that you want to protect via locking
* @param timeout - millis until giveup on getting the lock
* @return whether the lock was awarded
* @throws InterruptedException in case the thread was interrupted
*/
public boolean tryWriteLockOnKey(Object key, long timeout) throws InterruptedException {
Sync s = getLockForKey(key);
return s.tryLock(LockType.WRITE, timeout);
}
代码示例来源:origin: net.sf.ehcache.internal/ehcache-core
/**
* {@inheritDoc}
* <p>
* Only Terracotta clustered cache instances currently support querying a thread's read lock hold status.
*/
public boolean isReadLockedByCurrentThread(Object key) throws UnsupportedOperationException {
return getLockForKey(key).isHeldByCurrentThread(LockType.READ);
}
代码示例来源:origin: net.sf.ehcache.internal/ehcache-core
/**
* {@inheritDoc}
*/
public boolean isWriteLockedByCurrentThread(Object key) {
return getLockForKey(key).isHeldByCurrentThread(LockType.WRITE);
}
代码示例来源:origin: org.sonatype.nexus.bundles/org.sonatype.nexus.bundles.ehcache
/**
* {@inheritDoc}
*/
public boolean isWriteLockedByCurrentThread(Object key) {
return getLockForKey(key).isHeldByCurrentThread(LockType.WRITE);
}
代码示例来源:origin: org.sonatype.nexus.bundles/org.sonatype.nexus.bundles.ehcache
/**
* {@inheritDoc}
* <p>
* Only Terracotta clustered cache instances currently support querying a thread's read lock hold status.
*/
public boolean isReadLockedByCurrentThread(Object key) throws UnsupportedOperationException {
return getLockForKey(key).isHeldByCurrentThread(LockType.READ);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache
/**
* {@inheritDoc}
* <p>
* Only Terracotta clustered cache instances currently support querying a thread's read lock hold status.
*/
public boolean isReadLockedByCurrentThread(Object key) throws UnsupportedOperationException {
return getLockForKey(key).isHeldByCurrentThread(LockType.READ);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache
/**
* {@inheritDoc}
*/
public boolean isWriteLockedByCurrentThread(Object key) {
return getLockForKey(key).isHeldByCurrentThread(LockType.WRITE);
}
代码示例来源:origin: net.sf.ehcache.internal/ehcache-core
/**
* Try to get a read lock on a given key. If can't get it in timeout millis then
* return a boolean telling that it didn't get the lock
*
* @param key - The key that retrieves a value that you want to protect via locking
* @param timeout - millis until giveup on getting the lock
* @return whether the lock was awarded
* @throws InterruptedException in case the thread was interrupted
*/
public boolean tryReadLockOnKey(Object key, long timeout) throws InterruptedException {
Sync s = getLockForKey(key);
return s.tryLock(LockType.READ, timeout);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache
private void acquireLockOnKey(Object key, LockType lockType) {
Sync s = getLockForKey(key);
s.lock(lockType);
}
代码示例来源:origin: net.sf.ehcache.internal/ehcache-core
/**
* Try to get a write lock on a given key. If can't get it in timeout millis then
* return a boolean telling that it didn't get the lock
*
* @param key - The key that retrieves a value that you want to protect via locking
* @param timeout - millis until giveup on getting the lock
* @return whether the lock was awarded
* @throws InterruptedException in case the thread was interrupted
*/
public boolean tryWriteLockOnKey(Object key, long timeout) throws InterruptedException {
Sync s = getLockForKey(key);
return s.tryLock(LockType.WRITE, timeout);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache
private void releaseLockOnKey(Object key, LockType lockType) {
Sync s = getLockForKey(key);
s.unlock(lockType);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache
/**
* Try to get a read lock on a given key. If can't get it in timeout millis then
* return a boolean telling that it didn't get the lock
*
* @param key - The key that retrieves a value that you want to protect via locking
* @param timeout - millis until giveup on getting the lock
* @return whether the lock was awarded
* @throws InterruptedException
*/
public boolean tryReadLockOnKey(Object key, long timeout) throws InterruptedException {
Sync s = getLockForKey(key);
return s.tryLock(LockType.READ, timeout);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache
/**
* Try to get a write lock on a given key. If can't get it in timeout millis then
* return a boolean telling that it didn't get the lock
*
* @param key - The key that retrieves a value that you want to protect via locking
* @param timeout - millis until giveup on getting the lock
* @return whether the lock was awarded
* @throws InterruptedException
*/
public boolean tryWriteLockOnKey(Object key, long timeout) throws InterruptedException {
Sync s = getLockForKey(key);
return s.tryLock(LockType.WRITE, timeout);
}
代码示例来源:origin: org.sonatype.nexus.bundles/org.sonatype.nexus.bundles.ehcache
private void acquireLockOnKey(Object key, LockType lockType) {
Sync s = getLockForKey(key);
s.lock(lockType);
}
代码示例来源:origin: org.sonatype.nexus.bundles/org.sonatype.nexus.bundles.ehcache
private void releaseLockOnKey(Object key, LockType lockType) {
Sync s = getLockForKey(key);
s.unlock(lockType);
}
内容来源于网络,如有侵权,请联系作者删除!