Purging caches

Purge your scope’s caches

The CacheService service lets you perform getAll, clear and clearAll operations on your scope’s caches.

  • getAll allows you to retrieve all caches in the scope.

  • clearAll purges all your scope’s caches.

  • clear allows you to purge a list of caches defined by their name.

Cache retrieval

The following examples show how to retrieve the list of all FlowerDocs scope caches.


GET ALL:


# <CORE_HOST>  FlowerDocs Core base URL
# <TOKEN>      authentication token

curl -X GET "<CORE_HOST>/rest/caches" \
  -H "token: <TOKEN>"

@Autowired
private CacheService cacheService;

public String[] getAll() throws FunctionalException, TechnicalException
{
    List<String> cacheNames = cacheService.getAll();
    return cacheNames.toArray(new String[] {});
}

Cache purge

The examples below show how to purge FlowerDocs scope caches using the various operations of clear.


CLEAR ALL:


# <CORE_HOST>  FlowerDocs Core base URL
# <TOKEN>      authentication token

curl -X DELETE "<CORE_HOST>/rest/caches" \
  -H "token: <TOKEN>"

import com.flower.docs.domain.security.Roles;
import com.flower.docs.security.authorities.RoleEvaluator;

@Autowired
private CacheService cacheService;

public void clearAll() throws FunctionalException, TechnicalException
{
    cacheService.clearAll();
}


CLEAR:


# <CORE_HOST>  FlowerDocs Core base URL
# <TOKEN>      authentication token
# <NAMES>      name of caches to be purged

curl -X DELETE "<CORE_HOST>/rest/caches/<NAMES>" \
  -H "token: <TOKEN>"

@Autowired
private CacheService cacheService;

public void clear() throws FunctionalException, TechnicalException
    {
        List<String> cachesToClear = Lists.newArrayList("GEC-user", "GEC-DocumentClass");
        cacheService.clear(cachesToClear);
    }