/*
(non-Javadoc)

@see net.spy.memcached.internal.BulkFuture#getSome(long,
java.util.concurrent.TimeUnit)
344385
public Map<String, T> getSome(long to, TimeUnit unit)
    throws InterruptedException, ExecutionException {
    Collection<Operation> timedoutOps = new HashSet<Operation>();
    Map<String, T> ret = internalGet(to, unit, timedoutOps);
    if (timedoutOps.size() > 0) {
      timeout = true;
      LoggerFactory.getLogger(getClass()).warn(
          new CheckedOperationTimeoutException("Operation timed out: ",
              timedoutOps).getMessage());
    }
    return ret;

  }
1064406
@SuppressWarnings("unchecked")
  public final <T> Map<String, GetsResponse<T>> gets(final Collection<String> keyCollections,
      final long timeout, final Transcoder<T> transcoder)
      throws TimeoutException, InterruptedException, MemcachedException {
    return (Map<String, GetsResponse<T>>) this.getMulti0(keyCollections, timeout,
        CommandType.GETS_MANY, transcoder);
  }
122448
@Override
  public InetSocketAddress get(final Identifier key,
                               final Callable<InetSocketAddress> valueFetcher) throws ExecutionException {
    return cache.get(key, valueFetcher);
  }
1172189
@SuppressWarnings("unchecked")
  @Override
  public <T> T get(final Object key, final Callable<T> valueLoader) {
    try {
      return (T) cache.computeIfAbsent(key, (Callable<Object>) valueLoader);
    } catch (RuntimeException ex) {
      throw new ValueRetrievalException(key, valueLoader, ex);
    }
  }
592492
public final <T> Map<String, T> get(final Collection<String> keyCollections)
      throws TimeoutException, InterruptedException, MemcachedException {
    return this.get(keyCollections, this.opTimeout);
  }
535295
void get1(long id, Persistable object) throws TimeoutException {
        get1(GET, id, nonNullPersistable(object), null);
    }
1136856
public Long pexpireAt(Object key, long millisecondsTimestamp) {
		Jedis jedis = getJedis();
		try {
			return jedis.pexpireAt(keyToBytes(key), millisecondsTimestamp);
		}
		finally {close(jedis);}
	}
541071
public <E> CacheQuery<E> getQuery(HSQuery hSearchQuery, IndexedQueryMode queryMode) {
      if (timeoutExceptionFactory != null) {
         hSearchQuery.timeoutExceptionFactory(timeoutExceptionFactory);
      }
      Class<?>[] classes = hSearchQuery.getTargetedEntities().toPojosSet().toArray(new Class[hSearchQuery.getTargetedEntities().size()]);
      queryInterceptor.enableClasses(classes);

      if (queryMode == IndexedQueryMode.BROADCAST) {
         ExecutorService asyncExecutor = queryInterceptor.getAsyncExecutor();
         return new ClusteredCacheQueryImpl<>(new QueryDefinition(hSearchQuery), asyncExecutor, cache, keyTransformationHandler, null);
      } else {
         return new CacheQueryImpl<>(hSearchQuery, cache, keyTransformationHandler);
      }
   }
630543
CacheBucketOffset get(UUID keyHash, int generation) {
        CacheEntry entry;
        synchronized (this) {
            // First, check the tail cache.
            CacheBucketOffset tailOffset = this.tailOffsets.get(keyHash);
            if (tailOffset != null) {
                return tailOffset;
            }

            entry = this.cacheEntries.get(getHashGroup(keyHash));
        }

        // Check the Cache Entry.
        if (entry != null) {
            Long r = entry.get(keyHash, generation);
            if (r != null) {
                return CacheBucketOffset.decode(r);
            }
        }

        return null;
    }
45853
public long addAndGet(long delta)
      throws MemcachedException, InterruptedException, TimeoutException {
    if (delta >= 0) {
      return this.memcachedClient.incr(this.key, delta, this.initialValue);
    } else {
      return this.memcachedClient.decr(this.key, -delta, this.initialValue);
    }
  }
395728
@Override
	public V get(K key) throws CacheException {
		logger.debug("get key [" + key + "]");

		if (key == null) {
			return null;
		}

		try {
			Object redisCacheKey = getRedisCacheKey(key);
			byte[] rawValue = redisManager.get(keySerializer.serialize(redisCacheKey));
			if (rawValue == null) {
				return null;
			}
			V value = (V) valueSerializer.deserialize(rawValue);
			return value;
		} catch (SerializationException e) {
			throw new CacheException(e);
		}
	}
891174
@Override
    public synchronized Response get(long timeout, TimeUnit unit)
            throws InterruptedException, ExecutionException, TimeoutException {
        long now = System.currentTimeMillis();
        long mills = unit.toMillis(timeout);
        long toWait = mills;
        if (this.completed) {
            return this.getResult();
        } else if (toWait <= 0) {
            throw new TimeoutException("Timeout is smaller than 0.");
        } else {
            for (;;) {
                wait(toWait);
                if (this.completed) {
                    return this.getResult();
                }
                long gap = System.currentTimeMillis() - now;
                toWait = toWait - gap;
                if (toWait <= 0) {
                    throw new TimeoutException();
                }
            }
        }
    }
1245026
@ManagedOperation
    public V get(K key) {

        // 1. Try the L1 cache first
        if(l1_cache != null) {
            V val=l1_cache.get(key);
            if(val != null) {
                if(log.isTraceEnabled())
                    log.trace("returned value " + val + " for " + key + " from L1 cache");
                return val;
            }
        }

        // 2. Try the local cache
        Cache.Value<Value<V>> val=l2_cache.getEntry(key);
        Value<V> tmp;
        if(val != null) {
            tmp=val.getValue();
            if(tmp !=null) {
                V real_value=tmp.getVal();
                if(real_value != null && l1_cache != null && val.getTimeout() >= 0)
                    l1_cache.put(key, real_value, val.getTimeout());
                return tmp.getVal();
            }
        }

        // 3. Execute a cluster wide GET
        try {
            RspList<Object> rsps=disp.callRemoteMethods(null,
                                                new MethodCall(GET, key),
                                                new RequestOptions(ResponseMode.GET_ALL, call_timeout));
            for(Rsp rsp: rsps.values()) {
                Object obj=rsp.getValue();
                if(obj == null || obj instanceof Throwable)
                    continue;
                val=(Cache.Value<Value<V>>)rsp.getValue();
                if(val != null) {
                    tmp=val.getValue();
                    if(tmp != null) {
                        V real_value=tmp.getVal();
                        if(real_value != null && l1_cache != null && val.getTimeout() >= 0)
                            l1_cache.put(key, real_value, val.getTimeout());
                        return real_value;
                    }
                }
            }
            return null;
        }
        catch(Throwable t) {
            if(log.isWarnEnabled())
                log.warn("get() failed", t);
            return null;
        }
    }
1016046
@SuppressWarnings("unchecked")
  public final <T> GetsResponse<T> gets(final String key, final long timeout)
      throws TimeoutException, InterruptedException, MemcachedException {
    return this.gets(key, timeout, this.transcoder);
  }
444766
@SuppressWarnings("unchecked")
    public V get(final long key) {
        int index = longHash(key, mask);
        Object value;
        while (null != (value = values[index])) {
            if (key == keys[index]) {
                return (V) value;
            }
            index = ++index & mask;
        }
        return null;
    }
49481
public V get( final K key ) {
        synchronized ( _map ) {
            final ManagedItem<V> item = _map.get( key );
            if ( item == null ) {
                return null;
            }
            if ( _ttl > -1 && System.currentTimeMillis() - item._insertionTime > _ttl ) {
                _map.remove( key );
                return null;
            }
            return item._value;
        }
    }
323289
@Override
    protected R getFromCache(BaasBox box) throws BaasException {
        boolean handle = false;
        try {
            byte[] bytes = box.mCache.get(cacheKey());
            if (bytes == null) {
                Logger.info("GOT FROM CACHE MISS");
                return null;
            } else {
                Logger.info("GOT FROM CACHE HIT");
                handle = true;
                dataStream.startData(streamId(), bytes.length, null);
                dataStream.onData(bytes,bytes.length);
                return dataStream.endData(streamId(),bytes.length,null);
            }
        } catch (Exception e) {
            throw new BaasIOException("error while parsing content from cache", e);
        }finally {
            if(handle) dataStream.finishStream(streamId());
        }
    }