Examples of CacheValue


Examples of org.apache.jackrabbit.oak.cache.CacheValue

        // make sure we only cache the document if it wasn't
        // changed and cached by some other thread in the
        // meantime. That is, use get() with a Callable,
        // which is only used when the document isn't there
        try {
            CacheValue key = new StringValue(doc.getId());
            for (;;) {
                NodeDocument cached = nodesCache.get(key, new Callable<NodeDocument>() {
                    @Override
                    public NodeDocument call() {
                        return doc;
View Full Code Here

Examples of org.apache.jackrabbit.oak.cache.CacheValue

        } else if (oldDoc == null) {
            // this is an insert and some other thread was quicker
            // loading it into the cache -> return now
            return;
        } else {
            CacheValue key = new StringValue(newDoc.getId());
            // this is an update (oldDoc != null)
            if (Objects.equal(cached.getModCount(), oldDoc.getModCount())) {
                nodesCache.put(key, newDoc);
            } else {
                // the cache entry was modified by some other thread in
View Full Code Here

Examples of org.apache.jackrabbit.oak.cache.CacheValue

    private <T extends Document> void addToCacheIfNotNewer(Collection<T> collection, T doc) {
        if (collection == Collection.NODES) {
            String id = doc.getId();
            Lock lock = getAndLock(id);
            CacheValue cacheKey = new StringValue(id);
            try {
                // do not overwrite document in cache if the
                // existing one in the cache is newer
                NodeDocument cached = nodesCache.getIfPresent(cacheKey);
                if (cached != null && cached != NodeDocument.NULL) {
View Full Code Here

Examples of org.apache.jackrabbit.oak.cache.CacheValue

                                       boolean preferCached,
                                       final int maxCacheAge) {
        if (collection != Collection.NODES) {
            return findUncached(collection, key, DocumentReadPreference.PRIMARY);
        }
        CacheValue cacheKey = new StringValue(key);
        NodeDocument doc;
        if (maxCacheAge > 0 || preferCached) {
            // first try without lock
            doc = nodesCache.getIfPresent(cacheKey);
            if (doc != null) {
View Full Code Here

Examples of org.boxsql.cache.CacheValue

    private CacheDecorator() {
//     OK, Don't allow create a instance.
    }
   
    public static void addToCache(final String key, final String value){
        final CacheValue cacheValue = new CacheValue();
        cacheValue.setKey(key);
        cacheValue.setValue(value);
       
//        Clearing cache when it is full
        if(cache.size() == 60)
          cache.clear();
       
View Full Code Here

Examples of org.boxsql.cache.CacheValue

        return cached;
    }
   
   
    public static String getCachedValue(final String chave){
        CacheValue cacheValue = new CacheValue();
        cacheValue = cache.get(chave);
        return cacheValue.getValue();
    }
View Full Code Here

Examples of org.infinispan.server.core.CacheValue

   @Override
   public Object encodeValue(Object value) throws CodecException {
      if (value != null) {
         try {
            return new CacheValue(marshaller.objectToByteBuffer(value), 1);
         } catch (Exception e) {
            throw log.valueEncodingFailed(e, this.getName());
         }
      } else {
         return null;
View Full Code Here

Examples of org.infinispan.server.core.CacheValue

   @Override
   public Object decodeValue(Object value) throws CodecException {
      if (value != null) {
         try {
            CacheValue cv = (CacheValue) value;
            return marshaller.objectFromByteBuffer(cv.data());
         } catch (Exception e) {
            throw log.valueDecodingFailed(e, this.getName());
         }
      } else {
         return null;
View Full Code Here

Examples of org.infinispan.server.core.CacheValue

   }

   private InternalCacheEntry getInternalCacheEntry(Cache<ByteArrayKey, CacheValue> cache, String key, String value) throws Exception {
      InternalCacheEntry entry = cache.getAdvancedCache().getDataContainer().get(toBinaryKey(key));
      if (value != null) {
         CacheValue v = (CacheValue) entry.getValue();
         AssertJUnit.assertEquals(toBinaryValue(value), v.data());
      }
      return entry;
   }
View Full Code Here

Examples of org.infinispan.server.core.CacheValue

   private void assertCacheContains(Cache cache, String key, String value) throws Exception {
      Marshaller marshaller = new JBossMarshaller();
      byte[] keyBytes = marshaller.objectToByteBuffer(key, 64);
      byte[] valueBytes = marshaller.objectToByteBuffer(value, 64);
      ByteArrayKey cacheKey = new ByteArrayKey(keyBytes);
      CacheValue cacheValue = (CacheValue) cache.get(cacheKey);
      if (value == null) {
         assert cacheValue == null : "Expected null value but received: " + cacheValue;
      } else {
         assert Arrays.equals(valueBytes, (byte[])cacheValue.data());
      }
   }
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.