private Long withCaching(final OperationRetrieval<Long> op, @Nullable final UUID objectId, final ObjectType objectType, @Nullable final CacheController<Object, Object> cache) { if (objectId == null) { return null; } if (cache != null) { return (Long) cache.get(objectId.toString(), new CacheLoaderArgument(objectType)); } return op.doRetrieve(objectId, objectType); } }
@Override public Object load(final Object key, final Object argument) { checkCacheLoaderStatus(); if (!(key instanceof String)) { throw new IllegalArgumentException("Unexpected key type of " + key.getClass().getName()); } if (!(argument instanceof CacheLoaderArgument)) { throw new IllegalArgumentException("Unexpected key type of " + argument.getClass().getName()); } final Object[] args = ((CacheLoaderArgument) argument).getArgs(); final String tableName = (String) args[0]; final Long targetRecordId = (Long) args[1]; final InternalTenantContext internalTenantContext = (InternalTenantContext) args[2]; return auditSqlDao.getAuditLogsForTargetRecordId(tableName, targetRecordId, internalTenantContext); } }
@Override public Object load(final Object key, final Object argument) throws CacheException { checkCacheLoaderStatus(); if (!(key instanceof String)) { throw new IllegalArgumentException("Unexpected key type of " + key.getClass().getName()); } if (!(argument instanceof CacheLoaderArgument)) { throw new IllegalArgumentException("Unexpected key type of " + argument.getClass().getName()); } final String objectId = (String) key; final ObjectType objectType = ((CacheLoaderArgument) argument).getObjectType(); return nonEntityDao.retrieveRecordIdFromObject(UUID.fromString(objectId), objectType, null); } }
final CacheLoaderArgument cacheLoaderArgument = new CacheLoaderArgument(objectType, args, internalTenantContext); result = cache.get(cacheKey, cacheLoaderArgument);
@Override public Object load(final Object key, final Object argument) { checkCacheLoaderStatus(); if (!(key instanceof String)) { throw new IllegalArgumentException("Unexpected key type of " + key.getClass().getName()); } if (!(argument instanceof CacheLoaderArgument)) { throw new IllegalArgumentException("Unexpected key type of " + argument.getClass().getName()); } final String objectId = (String) key; final ObjectType objectType = ((CacheLoaderArgument) argument).getObjectType(); return nonEntityDao.retrieveTenantRecordIdFromObject(UUID.fromString(objectId), objectType, null); } }
@Override public Object load(final Object key, final Object argument) { checkCacheLoaderStatus(); if (!(key instanceof String)) { throw new IllegalArgumentException("Unexpected key type of " + key.getClass().getName()); } if (!(argument instanceof CacheLoaderArgument)) { throw new IllegalArgumentException("Unexpected key type of " + argument.getClass().getName()); } final Object[] args = ((CacheLoaderArgument) argument).getArgs(); final String tableName = (String) args[0]; final String historyTableName = (String) args[1]; final Long targetRecordId = (Long) args[2]; final InternalTenantContext internalTenantContext = (InternalTenantContext) args[3]; return auditSqlDao.getAuditLogsViaHistoryForTargetRecordId(tableName, historyTableName, targetRecordId, internalTenantContext); } }
private Long retrieveRecordIdFromCache(UUID tagId) { final CacheController<Object, Object> cache = controlCacheDispatcher.getCacheController(CacheType.RECORD_ID); Object result = null; if (cache != null) { // Keys are upper cased by convention result = cache.get(tagId.toString().toUpperCase(), new CacheLoaderArgument(ObjectType.TAG)); } return (Long) result; }
@Override public Object load(final Object key, final Object argument) { checkCacheLoaderStatus(); if (!(key instanceof String)) { throw new IllegalArgumentException("Unexpected key type of " + key.getClass().getName()); } if (!(argument instanceof CacheLoaderArgument)) { throw new IllegalArgumentException("Unexpected key type of " + argument.getClass().getName()); } final String objectId = (String) key; final ObjectType objectType = ((CacheLoaderArgument) argument).getObjectType(); return nonEntityDao.retrieveAccountRecordIdFromObject(UUID.fromString(objectId), objectType, null); } }