@SuppressWarnings("unchecked") private Long getExpiration(Fqn fqn) { NodeSPI n = cache.peek(fqn, false); if (n == null) return null; Long expiration = (Long) n.getDirect(config.getExpirationKeyName()); if ( expiration == null ) return -1L; return expiration; }
/** * Retrieves the value stored under a specified key in a node referenced by the specified Fqn. * * @return an Object of type V, stored under a specific key in a node for a given Fqn, or null if the Fqn refers to a node that does not exist. */ public Object perform(InvocationContext ctx) { NodeSPI n = ctx.lookUpNode(fqn); if (n == null) { if (trace) log.trace("Node not found"); return null; } if (n.isDeleted()) { if (trace) log.trace("Node has been deleted and is of type " + n.getClass().getSimpleName()); return null; } if (sendNodeEvent) notifier.notifyNodeVisited(fqn, true, ctx); Object result = n.getDirect(key); if (trace) log.trace("Found value " + result); if (sendNodeEvent) notifier.notifyNodeVisited(fqn, false, ctx); return result; }
public Object put(Fqn name, Object key, Object value) throws Exception { // DON'T make a remote call if this is a remote call in the first place - leads to deadlocks - JBCACHE-1103 if (!isCacheReady() || !cache.getInvocationContext().isOriginLocal()) return null; lock.acquireLock(name, true); try { NodeSPI n = cache.peek(name, false); if (n == null) { GetKeyValueCommand command = commandsFactory.buildGetKeyValueCommand(name, key, true); return callRemote(command); } else { // dont bother with a remote call return n.getDirect(key); } } finally { lock.releaseLock(name); } }
/** * Fetches the remove value, does not remove. Replication handles * removal. */ public Object remove(Fqn name, Object key) throws Exception { // DON'T make a remote call if this is a remote call in the first place - leads to deadlocks - JBCACHE-1103 if (!isCacheReady() || !cache.getInvocationContext().isOriginLocal()) return false; lock.acquireLock(name, true); try { NodeSPI n = cache.peek(name, true); if (n == null) { GetKeyValueCommand command = commandsFactory.buildGetKeyValueCommand(name, key, true); return callRemote(command); } else { // dont bother with a remote call return n.getDirect(key); } } finally { lock.releaseLock(name); } }