use of net.sf.ehcache.Element in project spring-security by spring-projects.
the class EhCacheBasedAclCache method getFromCache.
public MutableAcl getFromCache(ObjectIdentity objectIdentity) {
Assert.notNull(objectIdentity, "ObjectIdentity required");
Element element = null;
try {
element = cache.get(objectIdentity);
} catch (CacheException ignored) {
}
if (element == null) {
return null;
}
return initializeTransientFields((MutableAcl) element.getValue());
}
use of net.sf.ehcache.Element in project spring-security by spring-projects.
the class EhCacheBasedAclCache method putInCache.
public void putInCache(MutableAcl acl) {
Assert.notNull(acl, "Acl required");
Assert.notNull(acl.getObjectIdentity(), "ObjectIdentity required");
Assert.notNull(acl.getId(), "ID required");
if (this.aclAuthorizationStrategy == null) {
if (acl instanceof AclImpl) {
this.aclAuthorizationStrategy = (AclAuthorizationStrategy) FieldUtils.getProtectedFieldValue("aclAuthorizationStrategy", acl);
this.permissionGrantingStrategy = (PermissionGrantingStrategy) FieldUtils.getProtectedFieldValue("permissionGrantingStrategy", acl);
}
}
if ((acl.getParentAcl() != null) && (acl.getParentAcl() instanceof MutableAcl)) {
putInCache((MutableAcl) acl.getParentAcl());
}
cache.put(new Element(acl.getObjectIdentity(), acl));
cache.put(new Element(acl.getId(), acl));
}
use of net.sf.ehcache.Element in project spring-security by spring-projects.
the class EhCacheBasedTicketCache method putTicketInCache.
public void putTicketInCache(final CasAuthenticationToken token) {
final Element element = new Element(token.getCredentials().toString(), token);
if (logger.isDebugEnabled()) {
logger.debug("Cache put: " + element.getKey());
}
cache.put(element);
}
use of net.sf.ehcache.Element in project caffeine by ben-manes.
the class Ehcache2Policy method record.
@Override
public void record(long key) {
Object value = cache.get(key);
if (value == null) {
policyStats.recordMiss();
if (cache.getSize() == maximumSize) {
policyStats.recordEviction();
}
cache.put(new Element(key, key));
} else {
policyStats.recordHit();
}
}
use of net.sf.ehcache.Element in project gocd by gocd.
the class GoCache method put.
private void put(String key, Object value, Predicate predicate) {
logUnsavedPersistentObjectInteraction(value, "PersistentObject %s added to cache without an id.");
if (predicate.isTrue()) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(String.format("transaction active during cache put for %s = %s", key, value), new IllegalStateException());
}
return;
}
ehCache.put(new Element(key, value));
}
Aggregations