@Test public void testRemove() { SessionAwareCache<Cachable> cache = new SessionAwareCache<Cachable>("resultset", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.RESULTSET, 0); CacheID id = new CacheID(buildWorkContext(), new ParseInfo(), "SELECT * FROM FOO"); Cachable result = Mockito.mock(Cachable.class); Mockito.stub(result.prepare((BufferManager)anyObject())).toReturn(true); Mockito.stub(result.restore((BufferManager)anyObject())).toReturn(true); id = new CacheID(buildWorkContext(), new ParseInfo(), "SELECT * FROM FOO"); cache.put(id, Determinism.VDB_DETERMINISTIC, result, null); Object c = cache.get(id); assertTrue(result==c); assertTrue(cache.remove(id, Determinism.VDB_DETERMINISTIC) != null); assertNull(cache.get(id)); cache.put(id, Determinism.SESSION_DETERMINISTIC, result, null); assertTrue(cache.get(id) != null); assertTrue(cache.remove(id, Determinism.SESSION_DETERMINISTIC) != null); assertNull(cache.get(id)); }
public T remove(CacheID id, Determinism determinismLevel){ if (determinismLevel.compareTo(Determinism.SESSION_DETERMINISTIC) <= 0) { id.setSessionId(id.originalSessionId); LogManager.logTrace(LogConstants.CTX_DQP, "Removing from session/local cache", id); return this.localCache.remove(id); } id.setSessionId(null); if (determinismLevel == Determinism.USER_DETERMINISTIC) { id.setUserName(id.originalUserName); } else { id.setUserName(null); } LogManager.logTrace(LogConstants.CTX_DQP, "Removing from global/distributed cache", id); return this.distributedCache.remove(id); }
SessionAwareCache { public T remove(CacheID id, Determinism determinismLevel){ if (determinismLevel.compareTo(Determinism.SESSION_DETERMINISTIC) <= 0) { id.setSessionId(id.originalSessionId); LogManager.logTrace(LogConstants.CTX_DQP, "Removing from session/local cache", id); return this.localCache.remove(id); } id.setSessionId(null); if (determinismLevel == Determinism.USER_DETERMINISTIC) { id.setUserName(id.originalUserName); } else { id.setUserName(null); } LogManager.logTrace(LogConstants.CTX_DQP, "Removing from global/distributed cache", id); return this.distributedCache.remove(id); } }
SessionAwareCache { public T remove(CacheID id, Determinism determinismLevel){ if (determinismLevel.compareTo(Determinism.SESSION_DETERMINISTIC) <= 0) { id.setSessionId(id.originalSessionId); LogManager.logTrace(LogConstants.CTX_DQP, "Removing from session/local cache", id); return this.localCache.remove(id); } id.setSessionId(null); if (determinismLevel == Determinism.USER_DETERMINISTIC) { id.setUserName(id.originalUserName); } else { id.setUserName(null); } LogManager.logTrace(LogConstants.CTX_DQP, "Removing from global/distributed cache", id); return this.distributedCache.remove(id); } SessionAwareCache(String cacheName, final CacheFactory cacheFactory, final Type type, int maxStaleness); }
SessionAwareCache { public T remove(CacheID id, Determinism determinismLevel){ if (determinismLevel.compareTo(Determinism.SESSION_DETERMINISTIC) <= 0) { id.setSessionId(id.originalSessionId); LogManager.logTrace(LogConstants.CTX_DQP, "Removing from session/local cache", id); return this.localCache.remove(id); } id.setSessionId(null); if (determinismLevel == Determinism.USER_DETERMINISTIC) { id.setUserName(id.originalUserName); } else { id.setUserName(null); } LogManager.logTrace(LogConstants.CTX_DQP, "Removing from global/distributed cache", id); return this.distributedCache.remove(id); } SessionAwareCache(String cacheName, final CacheFactory cacheFactory, final Type type, int maxStaleness); T get(CacheID id); int getCacheHitCount(); int getRequestCount(); int getCachePutCount(); int getTotalCacheEntries(); T remove(CacheID id, Determinism determinismLevel); void put(CacheID id, Determinism determinismLevel, T t, Long ttl); void clearAll(); void clearForVDB(String vdbName, String version); void clearForVDB(VDBKey vdbKey); void setTupleBufferCache(TupleBufferCache bufferManager); void setModTime(long modTime); static Collection<String> getCacheTypes(); boolean isTransactional(); double getCacheHitRatio(); CacheStatisticsMetadata buildCacheStats(String name); }
SessionAwareCache { public T remove(CacheID id, Determinism determinismLevel){ if (determinismLevel.compareTo(Determinism.SESSION_DETERMINISTIC) <= 0) { id.setSessionId(id.originalSessionId); LogManager.logTrace(LogConstants.CTX_DQP, "Removing from session/local cache", id); return this.localCache.remove(id); } id.setSessionId(null); if (determinismLevel == Determinism.USER_DETERMINISTIC) { id.setUserName(id.originalUserName); } else { id.setUserName(null); } LogManager.logTrace(LogConstants.CTX_DQP, "Removing from global/distributed cache", id); return this.distributedCache.remove(id); } SessionAwareCache(String cacheName, final CacheFactory cacheFactory, final Type type, int maxStaleness); T get(CacheID id); int getCacheHitCount(); int getRequestCount(); int getCachePutCount(); int getTotalCacheEntries(); T remove(CacheID id, Determinism determinismLevel); void put(CacheID id, Determinism determinismLevel, T t, Long ttl); void clearAll(); void clearForVDB(String vdbName, String version); void clearForVDB(VDBKey vdbKey); void setTupleBufferCache(TupleBufferCache bufferManager); void setModTime(long modTime); static Collection<String> getCacheTypes(); boolean isTransactional(); double getCacheHitRatio(); CacheStatisticsMetadata buildCacheStats(String name); static final String REPL; static final int DEFAULT_MAX_SIZE_TOTAL; }