Package org.springframework.cache.Cache

Examples of org.springframework.cache.Cache.ValueWrapper


   */
  public void collectAgentSystemData() {
    Ehcache nativeCache = (Ehcache) agentMonitoringTargetsCache.getNativeCache();
    List<String> keysWithExpiryCheck = cast(nativeCache.getKeysWithExpiryCheck());
    for (String each : keysWithExpiryCheck) {
      ValueWrapper value = agentMonitoringTargetsCache.get(each);
      AgentControllerIdentityImplementation agentIdentity = cast(value.get());
      if (agentIdentity != null) {
        // Is Same Region
        if (isCurrentRegion(agentIdentity)) {
          try {
            updateSystemStat(agentIdentity);
View Full Code Here


    }

    @Override
    public Serializable get(String key) {
        LOGGER.debug("Get cache with key: [{}]", key);
        final ValueWrapper valueWrapper = this.cache.get(key);
        Serializable value = null;

        if (valueWrapper != null) {

            final CacheWrapper cacheWrapper = (CacheWrapper) valueWrapper.get();

            if (cacheWrapper.isExpire()) {
                this.cache.evict(key);
            } else {
                value = cacheWrapper.getValue();
View Full Code Here

    Timer timer = new Timer(getCachedUri(request));
    timer.start();

    String key = calculateKey(request);
    PageInfo pageInfo;
    ValueWrapper element = cacheStatus.valueWrapper;
    try {
      log.debug("Serving cached content for {}", key);
      pageInfo = (PageInfo) element.get();

      for (Map.Entry<String, ? extends Serializable> entry : pageInfo.getRequestAttributes().entrySet()) {
        request.setAttribute(entry.getKey(), entry.getValue());
      }
View Full Code Here

    boolean trace = log.isTraceEnabled();
    boolean updateRequired = false;
    boolean atLeastOne = false;

    ValueWrapper valueWrapper = null;

    for (CacheOperationContext context : cacheables) {
      if (context.isConditionPassing()) {
        atLeastOne = true;
        Object key = context.generateKey();

        if (trace) {
          log.trace("Computed cache key {} for operation {}", new Object[] { key, context.operation });
        }
        if (key == null) {
          throw new IllegalArgumentException(
              "Null key returned for cache operation (maybe you are using named params on classes without debug info?) " +
              context.operation);
        }

        // add op/key (in case an update is discovered later on)
        cUpdates.put(context, key);

        boolean localCacheHit = false;

        // check whether the cache needs to be inspected or not (the method will be invoked anyway)
        if (!updateRequired) {
          for (Cache cache : context.getCaches()) {
            ValueWrapper wrapper = cache.get(key);
            if (wrapper != null) {
              valueWrapper = wrapper;
              localCacheHit = true;
              break;
            }
View Full Code Here

      response.getWriter().write(page);
    }
  }

  protected void update(Collection<Cache> caches, PageInfo pageInfo, CacheStatus cacheStatus, String key) {
    ValueWrapper element = cacheStatus == null ? null : cacheStatus.valueWrapper;
    Object maxAge = pageInfo.getCacheDirectives().get("max-age");
    int timeToLive = (maxAge instanceof Integer) ? ((Integer)maxAge) : (int)pageInfo.getTimeToLiveSeconds();
    for (Cache cache : caches) {
      log.debug("Response ok. Adding to cache {} with key {} and ttl {}",
          new Object[] { cache.getName(), key, getTimeToLive(element) });
View Full Code Here

    Object value = getValue();

    assertNotNull(value);
    assertNull(cache.get(key));
    cache.put(key, value);
    ValueWrapper valueWrapper = cache.get(key);
    if (valueWrapper != null) {
      assertThat(valueWrapper.get(), isEqual(value));
    }
    // keeps failing on the CI server so do
    else {
      // Thread.sleep(200);
      // assertNotNull(cache.get(key));
View Full Code Here

    cache.put(key3, value3);
    cache.put(key4, value4);

    assertNull(cache.get(key1));
    assertNull(cache.get(key2));
    ValueWrapper valueWrapper = cache.get(k1);
    assertNotNull(valueWrapper);
    assertThat(valueWrapper.get(), isEqual(v1));
  }
View Full Code Here

   
    Object key = getKey();
    template.delete(key);

    Object value = getValue();
    ValueWrapper wrapper = redisCache.putIfAbsent(key, value);

    assertThat(wrapper.get(), sameInstance(value));

    ValueWrapper wrapper2 = redisCache.putIfAbsent(key, value);

    if (!(value instanceof Number)) {
      assertThat(wrapper2.get(), not(sameInstance(value)));
    }

    assertThat(wrapper2.get(), equalTo(value));
  }
View Full Code Here

    User result = repository.findByUsername("dmatthews");
    assertThat(result, is(dave));

    // Verify entity cached
    Cache cache = cacheManager.getCache("byUsername");
    ValueWrapper wrapper = cache.get("dmatthews");
    assertThat(wrapper.get(), is((Object) dave));
  }
View Full Code Here

TOP

Related Classes of org.springframework.cache.Cache.ValueWrapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.