@Override
 public void delete(Long scheduleId, Long id) {
   super.delete(scheduleId, id);
   Object entityCacheKey = getEntityCacheKey(Job.class, getJobWideUniqueData(scheduleId, id));
   cache.remove(entityCacheKey);
   abandonScheduleCache(scheduleId);
 }
  /** Removes a session from the cache and deletes it from the backing store, if applicable. */
  public void removeSession(String sessionId) {
    _sessions.remove(sessionId);

    if (_persistentStore != null) _persistentStore.remove(sessionId);

    remove(sessionId);
  }
  @Test
  public void testJSRExample1() throws InterruptedException {
    final String cacheName = randomString();

    CacheManager cacheManager = cachingProvider1.getCacheManager();
    assertNotNull(cacheManager);

    assertNull(cacheManager.getCache(cacheName));

    CacheConfig<Integer, String> config = new CacheConfig<Integer, String>();
    Cache<Integer, String> cache = cacheManager.createCache(cacheName, config);
    assertNotNull(cache);

    assertTrueEventually(
        new AssertTask() {
          @Override
          public void run() throws Exception {
            CacheManager cm2 = cachingProvider2.getCacheManager();
            assertNotNull(cm2.getCache(cacheName));
          }
        });

    Integer key = 1;
    String value1 = "value";
    cache.put(key, value1);

    String value2 = cache.get(key);
    assertEquals(value1, value2);
    cache.remove(key);
    assertNull(cache.get(key));

    Cache<Integer, String> cache2 = cacheManager.getCache(cacheName);
    assertNotNull(cache2);

    key = 1;
    value1 = "value";
    cache.put(key, value1);

    value2 = cache.get(key);
    assertEquals(value1, value2);
    cache.remove(key);
    assertNull(cache.get(key));

    cacheManager.destroyCache(cacheName);
    cacheManager.close();
  }
 private void clearConfigCache() {
   Cache workflowCache =
       Caching.getCacheManager(APIConstants.API_MANAGER_CACHE_MANAGER)
           .getCache(APIConstants.WORKFLOW_CACHE_NAME);
   String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
   String cacheName = tenantDomain + "_" + APIConstants.WORKFLOW_CACHE_NAME;
   if (workflowCache.containsKey(cacheName)) {
     workflowCache.remove(cacheName);
   }
 }
  @Test
  public void testJCacheGettingStarted() {
    try (CachingProvider provider = Caching.getCachingProvider();
        CacheManager manager = provider.getCacheManager();
        Cache<String, String> cache =
            manager.createCache("testCache", new MutableConfiguration<>())) {
      cache.put("key", "value");
      assertThat(cache.get("key")).isEqualTo("value");

      cache.remove("key");
      assertThat(cache.get("key")).isNull();
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see es.alvsanand.webpage.services.admin.WebAdminService#eraseCache()
   */
  public void eraseCache() {
    Cache cache;

    try {
      logger.debug("Erasing cache data");

      CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
      cache = cacheFactory.createCache(Collections.emptyMap());

      for (String cacheName : Globals.CAHE_NAMES) {
        cache.remove(cacheName);
      }
    } catch (CacheException cacheException) {
      logger.error("Error removing erasing cache data.", cacheException);
    }
  }
  @SuppressWarnings("unchecked")
  @Override
  public Object put(Object key, Object value) {
    map.put(key, value);
    try {
      return cache.put(key, value);
    } catch (MemcacheServiceException e) {
      //  TODO Split the value into smaller pieces and store them separately?
      logger.warn("Error putting value into cache", e);

      //  A value may be already in cache. We should remove it to avoid
      //  not synchronous duplicates there and here in local map.
      cache.remove(key);

      return null;
    }
  }
 public Object remove(Object arg0) {
   localCache.remove(arg0);
   return cache.remove(arg0);
 }
 private void abandonJobsByCronStringCache(String cronString) {
   Object entityCacheKey = getEntityCacheKey(Job.class, cronString);
   cache.remove(entityCacheKey);
 }
 private void abandonScheduleCache(Long scheduleId) {
   Object entityCacheKey = getEntityCacheKey(Schedule.class, scheduleId);
   cache.remove(entityCacheKey);
 }
 @Override
 public Object remove(Object key) {
   map.remove(key);
   return cache.remove(key);
 }