Search in sources :

Example 21 with FF4jCacheProxy

use of org.ff4j.cache.FF4jCacheProxy in project ff4j by ff4j.

the class PropertyStoreResource method clear.

/**
 * 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();
}
Also used : FF4jCacheProxy(org.ff4j.cache.FF4jCacheProxy) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

FF4jCacheProxy (org.ff4j.cache.FF4jCacheProxy)21 InMemoryCacheManager (org.ff4j.cache.InMemoryCacheManager)9 Test (org.junit.Test)9 Given (cucumber.api.java.en.Given)5 InMemoryFeatureStore (org.ff4j.store.InMemoryFeatureStore)5 PropertyString (org.ff4j.property.PropertyString)3 InMemoryPropertyStore (org.ff4j.property.store.InMemoryPropertyStore)3 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 HashSet (java.util.HashSet)2 POST (javax.ws.rs.POST)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 FF4JCacheManager (org.ff4j.cache.FF4JCacheManager)2 Feature (org.ff4j.core.Feature)2 FeatureStore (org.ff4j.core.FeatureStore)2 Property (org.ff4j.property.Property)2 FileItem (org.apache.commons.fileupload.FileItem)1 DiskFileItemFactory (org.apache.commons.fileupload.disk.DiskFileItemFactory)1 ServletFileUpload (org.apache.commons.fileupload.servlet.ServletFileUpload)1