cacheManager.clearFeatures(); cacheManager.putFeature(f); cacheManager.clearProperties(); cacheManager.putProperty(p);
/** * TDD. */ @Test public void testClear() { // Given getCacheManager().putFeature(new Feature("ff", false, DESCRIPTION)); getCacheManager().putFeature(new Feature("ff2", false, DESCRIPTION)); getCacheManager().putFeature(new Feature("ff3", false, DESCRIPTION)); Assert.assertEquals(3, getCacheManager().listCachedFeatureNames().size()); // When getCacheManager().clearFeatures(); // Then Assert.assertTrue(getCacheManager().listCachedFeatureNames().isEmpty()); }
/** * TDD. */ @Test public void testEvictOK() { // Given getCacheManager().putFeature(new Feature("ff", false, DESCRIPTION)); Assert.assertTrue(getCacheManager().listCachedFeatureNames().contains("ff")); // When getCacheManager().evictFeature("ff"); // Then Assert.assertFalse(getCacheManager().listCachedFeatureNames().contains("ff")); }
@After /** Clean cache. */ public void clean() { getCacheManager().clearFeatures(); getCacheManager().clearProperties(); }
/** * TDD. */ @Test public void testEvictFeatureNotExist() { // Given Assert.assertFalse(getCacheManager().listCachedFeatureNames().contains("ff")); // When getCacheManager().evictFeature("ff"); // Then // .. everything OK... }
/** * POST Operation to clean cache. */ @POST @Path("/" + RESOURCE_CACHE) @Produces(MediaType.TEXT_PLAIN) @ApiOperation(value= "Clear Cache", response=Response.class) @ApiResponses({ @ApiResponse(code = 200, message= "cache is cleard"), @ApiResponse(code = 404, message= "no cache content provided") }) public Response clear() { FF4jCacheProxy cacheProxy = ff4j.getCacheProxy(); if (cacheProxy == null) { return Response.status(Response.Status.NOT_FOUND).entity("Current Store is not cached").build(); } cacheProxy.getCacheManager().clearFeatures(); return Response.ok("Cache has been cleared").build(); }
/** * POST Operation to clean cache. */ @POST @Path("/" + RESOURCE_CACHE) @Produces(MediaType.TEXT_PLAIN) @ApiOperation(value= "Clear Cache", response=Response.class) @ApiResponses({ @ApiResponse(code = 200, message= "cache is cleard"), @ApiResponse(code = 404, message= "no cache content provided") }) public Response clear() { FF4jCacheProxy cacheProxy = ff4j.getCacheProxy(); if (cacheProxy == null) { return Response.status(Response.Status.NOT_FOUND).entity("Current Store is not cached").build(); } cacheProxy.getCacheManager().clearProperties(); return Response.ok("Cache has been cleared").build(); }
/** * TDD. */ @Test public void testPutSeveral() { // Given Assert.assertTrue(getCacheManager().listCachedFeatureNames().isEmpty()); // When getCacheManager().putFeature(new Feature("ff", false, DESCRIPTION)); getCacheManager().putFeature(new Feature("ff2", false, DESCRIPTION)); // Then Assert.assertEquals(2, getCacheManager().listCachedFeatureNames().size()); }
/** {@inheritDoc} */ @Override public void delete(String featureId) { // Access target store getTargetFeatureStore().delete(featureId); // even is not present, evict won't failed getCacheManager().evictFeature(featureId); }
public CacheApiBean(FeatureStore featureStore) { if (featureStore instanceof FF4jCacheProxy) { FF4jCacheProxy cacheProxy = (FF4jCacheProxy) featureStore; cacheStore = cacheProxy.getCachedTargetStore(); cacheProvider = cacheProxy.getCacheProvider(); featureNames = cacheProxy.getCacheManager().listCachedFeatureNames(); } }
/** {@inheritDoc} */ @Override public Feature read(String featureUid) { Feature fp = getCacheManager().getFeature(featureUid); // not in cache but may has been created from now if (null == fp) { fp = getTargetFeatureStore().read(featureUid); getCacheManager().putFeature(fp); } return fp; }
/** {@inheritDoc} */ public String getCacheProvider() { if (cacheManager != null) { return cacheManager.getCacheProviderName(); } else { return null; } }
public CacheApiBean(PropertyStore propertyStore) { if (propertyStore instanceof FF4jCacheProxy) { FF4jCacheProxy cacheProxy = (FF4jCacheProxy) propertyStore; // FIXME : This is wrong. Need to ask Cedrick to change the implementation for property cacheStore = cacheProxy.getCachedTargetStore(); cacheProvider = cacheProxy.getCacheProvider(); propertyNames = cacheProxy.getCacheManager().listCachedPropertyNames(); } }
/** {@inheritDoc} */ @Override public void create(Feature fp) { getTargetFeatureStore().create(fp); getCacheManager().putFeature(fp); }
/** {@inheritDoc} */ @Override public void clear() { // Cache Operations : As modification, flush cache for this getCacheManager().clearProperties(); getTargetPropertyStore().clear(); // Cache Operations : As modification, flush cache for this getCacheManager().clearFeatures(); getTargetFeatureStore().clear(); }
/** {@inheritDoc} */ public void importFeatures(Collection<Feature> features) { getCacheManager().clearFeatures(); getTargetFeatureStore().importFeatures(features); }
/** {@inheritDoc} */ public void importProperties(Collection<Property<?>> properties) { getCacheManager().clearProperties(); getTargetPropertyStore().importProperties(properties); }
/** * TDD. */ @Test public void testPutAvoidDoublon() { // Given Assert.assertTrue(getCacheManager().listCachedFeatureNames().isEmpty()); // When getCacheManager().putFeature(new Feature("ff", false, DESCRIPTION)); getCacheManager().putFeature(new Feature("ff", false, DESCRIPTION)); getCacheManager().putFeature(new Feature("ff2", false, DESCRIPTION)); // Then Assert.assertEquals(2, getCacheManager().listCachedFeatureNames().size()); }
/** {@inheritDoc} */ @Override public void disable(String featureId) { // Reach target getTargetFeatureStore().disable(featureId); // Cache Operations : As modification, flush cache for this getCacheManager().evictFeature(featureId); }
/** * Constructor from its feature store. * * @param featureStore * cuurent fature store */ public CacheApiBean(FeatureStore featureStore) { if (featureStore instanceof FF4jCacheProxy) { FF4jCacheProxy cacheProxy = (FF4jCacheProxy) featureStore; cacheStore = cacheProxy.getCachedTargetStore(); cacheProvider = cacheProxy.getCacheProvider(); featureNames = cacheProxy.getCacheManager().listCachedFeatureNames(); } }