Examples of CacheEntry


Examples of at.newmedialab.ldclient.model.CacheEntry

        lockResource(resource);
        try {

            // 2. check whether the resource has a cache entry; if no, goto 4
            CacheEntry entry = getCacheEntry(resource);

            // 3. check whether the expiry time of the cache entry has passed; if no, returns immediately
            if(entry != null && entry.getExpiryDate().after(new Date())) {
                log.info("not refreshing resource {}, as the cached entry is not yet expired",resource);
                return;
            }

            // 4.
            log.debug("refreshing resource {}",resource);
            try {
                ClientResponse response = clientService.retrieveResource(resource);

                if(response != null) {
                    log.info("refreshed resource {}",resource);

                    URI context = cacheProvider.getTripleRepository().getValueFactory().createURI(CTX_CACHE);


                    RepositoryConnection lmfConnection = cacheProvider.getTripleRepository().getConnection();
                    RepositoryConnection respConnection = response.getTriples().getConnection();

                    lmfConnection.remove(resource,null,null,context);


                    RepositoryResult<Statement> triples = respConnection.getStatements(null,null,null,true);
                    while(triples.hasNext()) {
                        Statement triple = triples.next();
                        try {
                            lmfConnection.add(triple,context);
                        } catch (RuntimeException ex) {
                            log.warn("not adding triple {}: an exception occurred ({})",triple,ex.getMessage());
                        }
                    }
                    lmfConnection.commit();

                    lmfConnection.close();
                    respConnection.close();

                    CacheEntry newEntry = new CacheEntry();
                    newEntry.setResource(resource);
                    newEntry.setExpiryDate(response.getExpires());
                    newEntry.setLastRetrieved(new Date());
                    if(entry != null) {
                        newEntry.setUpdateCount(entry.getUpdateCount()+1);
                    } else {
                        newEntry.setUpdateCount((long)1);
                    }

                    cacheProvider.getMetadataRepository().put(resource.stringValue(),newEntry);

                }

            } catch (LDClientException e) {
                // on exception, save an expiry information and retry in one day
                CacheEntry newEntry = new CacheEntry();
                newEntry.setResource(resource);
                newEntry.setExpiryDate(new Date(System.currentTimeMillis() + config.getInt("expiry", 86400)*1000));
                newEntry.setLastRetrieved(new Date());
                if(entry != null) {
                    newEntry.setUpdateCount(entry.getUpdateCount()+1);
                } else {
                    newEntry.setUpdateCount((long)1);
                }

                cacheProvider.getMetadataRepository().put(resource.stringValue(), newEntry);

                log.error("refreshing the remote resource {} from the Linked Data Cloud failed ({})",resource,e.getMessage());
View Full Code Here

Examples of com.gistlabs.mechanize.cache.api.CacheEntry

    return chain.execute(request, context);
  }

  public HttpResponse executeGET(final HttpUriRequest request, final HttpContext context, final MechanizeFilter chain) {
    String uri = request.getURI().toString();
    CacheEntry previous = cache.get(uri);
    if (previous!=null && previous.isValid())
      return previous.getResponse();

    if (previous!=null)
      previous.prepareConditionalGet(request);

    HttpResponse response = chain.execute(request, context); // call the chain

    if (response.getStatusLine().getStatusCode()==304) // not modified
      return previous.updateCacheValues(response).getResponse();

    CacheEntry maybe = generateCacheEntry(request, response);

    if (maybe.isCacheable())
      store(uri, previous, maybe);

    return response;
  }
View Full Code Here

Examples of com.gistlabs.mechanize.cache.api.CacheEntry

    return new InMemoryCacheEntry(request, response);
  }

  public HttpResponse executeHEAD(final HttpUriRequest request, final HttpContext context, final MechanizeFilter chain) {
    String uri = request.getURI().toString();
    CacheEntry previous = cache.get(uri);

    if (previous!=null && previous.isValid())
      return previous.head();

    if (previous!=null)
      previous.prepareConditionalGet(request);

    HttpResponse response = chain.execute(request, context); // call the chain

    if (previous!=null)
      previous.updateCacheValues(response);

    return response;
  }
View Full Code Here

Examples of com.linkedin.databus.client.pub.FileSystemCheckpointPersistenceProvider.CacheEntry

    if (streamFile.exists())
    {
      assertTrue(streamFile.delete());
    }

    CacheEntry cacheEntry = checkpointProvider.new CacheEntry(streamId, null);
    Checkpoint checkpoint = cacheEntry.getCheckpoint();
    assertNull(checkpoint);
  }
View Full Code Here

Examples of com.opensymphony.oscache.base.CacheEntry

                /** OpenSymphony BEGIN */
                if (!unlimitedDiskCache && !overflowPersistence) {
                    persistRemove(e.key);
                    // If we have a CacheEntry, update the groups
                    if (oldValue instanceof CacheEntry) {
                      CacheEntry oldEntry = (CacheEntry)oldValue;
                      removeGroupMappings(oldEntry.getKey(),
                          oldEntry.getGroups(), true);
                }
                } else {
                  // only remove from memory groups
                  if (oldValue instanceof CacheEntry) {
                    CacheEntry oldEntry = (CacheEntry)oldValue;
                    removeGroupMappings(oldEntry.getKey(),
                        oldEntry.getGroups(), false);
                  }
                }

                if (overflowPersistence && ((size() + 1) >= maxEntries)) {
                    persistStore(key, oldValue);
                    // add key to persistent groups but NOT to the memory groups
                    if (oldValue instanceof CacheEntry) {
                      CacheEntry oldEntry = (CacheEntry)oldValue;
                      addGroupMappings(oldEntry.getKey(), oldEntry.getGroups(), true, false);
                    }
                }

                if (invokeAlgorithm) {
                    itemRemoved(key);
View Full Code Here

Examples of com.volantis.cache.CacheEntry

        AsyncResult async = cache.asyncQuery(cacheKey, Period.inSeconds(30));

        assertFalse(async.isReady());

        CacheEntry entry = async.getEntry();
        assertNotNull(entry);

        final SystemClock clock = SystemClock.getDefaultInstance();
        ProviderResult result = new ProviderResult(new Integer(1),
            cache.getRootGroup(), true,
View Full Code Here

Examples of com.volantis.mcs.cache.CacheEntry

        cacheTime.expects.getTimeInMillis().returns(Integer.MAX_VALUE);

        // Create a new DefaultCacheStore with a TTL of 100
        CacheStore defaultCacheStore = new DefaultCacheStore(cacheTime,100);

        CacheEntry entry1 = new CSSCacheEntry(writableCSSEntityMock1);
        CacheEntry entry2 = new CSSCacheEntry(writableCSSEntityMock2, 50);
        CacheEntry entry3 = new CSSCacheEntry(writableCSSEntityMock2, 150);

        // We add the first identity which should get a cacheTime of 0,
        // expiresTime of 100 and a sequence number of 0
        CacheIdentity identity1 = defaultCacheStore.store(entry1);
        assertEquals("T1", identity1.getCreateTime(),0);
View Full Code Here

Examples of javax.cache.CacheEntry

      return true;

    if (lastCheck + UPDATE_CHECK_INTERVAL > now)
      return false;

    CacheEntry entry = _authStore.getCacheEntry(ADMIN_AUTH_MAP_KEY);

    if (entry != null && entry.getLastUpdateTime() > lastCheck)
      return true;

    return false;
  }
View Full Code Here

Examples of mitza.dynamic.compile.cache.CacheEntry

  }

  @Override
  protected Class<?> findClass(String name) throws ClassNotFoundException {
    ClassLoaderCache cache = ClassLoaderCache.getInstance();
    CacheEntry cacheEntry = cache.get(name);
    if (cacheEntry != null && cacheEntry.getLastModified() > lastModified) {
      log.debug("Return class '{}' from cache", name);
      return cacheEntry.getClazz();
    }

    Class<?> clazz = createExecutorClass(name);
    cache.put(name, clazz);
    log.debug("Add class '{}' to cache, size {}", name, cache.size());
View Full Code Here

Examples of net.sf.ehcache.CacheEntry

        throws CacheException
    {
        Element removed = remove( key );
        if ( writerManager != null )
        {
            writerManager.remove( new CacheEntry( key, removed ) );
        }
        return removed;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.