Reads a value from the cache by probing the in-memory cache, and if enabled and the in-memory
probe was a miss, the disk cache.

@param elementKey
the cache key
@return the cached value, or null if element was not cached
488445
@SuppressWarnings("unchecked")
    public synchronized ValT get(Object elementKey) {
        KeyT key = (KeyT) elementKey;
        ValT value = cache.get(key);
        if (value != null) {
            // memory hit
            Log.d(name, "MEM cache hit for " + key.toString());
            return value;
        }

        // memory miss, try reading from disk
        File file = getFileForKey(key);
        if (file.exists()) {
        	// if file older than expirationInMinutes, remove it
        	long lastModified = file.lastModified();
        	Date now = new Date();
        	long ageInMinutes = ((now.getTime() - lastModified) / (1000*60));
        	
        	if (ageInMinutes >= expirationInMinutes) {
        		Log.d(name, "DISK cache expiration for file " + file.toString());
        		file.delete();
        		return null;
        	}
        	
        	// disk hit
            Log.d(name, "DISK cache hit for " + key.toString());
            try {
                value = readValueFromDisk(file);
            } catch (IOException e) {
                // treat decoding errors as a cache miss
                e.printStackTrace();
                return null;
            }
            if (value == null) {
                return null;
            }
            cache.put(key, value);
            return value;
        }

        // cache miss
        return null;
    }
472012
public static String getAttribute( Element node, String key )
    {
        return getAttribute( node, key, null );
    }
398072
JsonNode readCacheFile()
  {
    if (cacheFile == null || !this.checkCacheLockFile())
    {
      // no cache or the cache is not valid.
      return null;
    }
    try
    {
      if (!cacheFile.exists())
      {
        LOGGER.debug(
            "Cache file doesn't exists. File: {}", cacheFile);
        return null;
      }

      try (Reader reader = new InputStreamReader(
          new FileInputStream(cacheFile), DEFAULT_FILE_ENCODING))
      {
        return OBJECT_MAPPER.readTree(reader);
      }
    }
    catch (IOException ex)
    {
      LOGGER.debug(
          "Failed to read the cache file. No worry. File: {}, Err: {}",
          cacheFile, ex);
    }
    return null;
  }
475838
private @Nullable PooledByteBuffer readFromDiskCache(final CacheKey key) throws IOException {
    try {
      FLog.v(TAG, "Disk cache read for %s", key.getUriString());

      final BinaryResource diskCacheResource = mFileCache.getResource(key);
      if (diskCacheResource == null) {
        FLog.v(TAG, "Disk cache miss for %s", key.getUriString());
        mImageCacheStatsTracker.onDiskCacheMiss();
        return null;
      } else {
        FLog.v(TAG, "Found entry in disk cache for %s", key.getUriString());
        mImageCacheStatsTracker.onDiskCacheHit(key);
      }

      PooledByteBuffer byteBuffer;
      final InputStream is = diskCacheResource.openStream();
      try {
        byteBuffer = mPooledByteBufferFactory.newByteBuffer(is, (int) diskCacheResource.size());
      } finally {
        is.close();
      }

      FLog.v(TAG, "Successful read from disk cache for %s", key.getUriString());
      return byteBuffer;
    } catch (IOException ioe) {
      // TODO: 3697790 log failures
      // TODO: 5258772 - uncomment line below
      // mFileCache.remove(key);
      FLog.w(TAG, ioe, "Exception reading from cache for %s", key.getUriString());
      mImageCacheStatsTracker.onDiskCacheGetFail();
      throw ioe;
    }
  }
9252
public V get(K key) {
    V value = _cacheImpl.get(key);
    _requests.incrementAndGet();
    if (value == null) {
      value = _missHandler.load(key);
      _cacheImpl.put(key, value);
      _misses.incrementAndGet();
    } else {
      _hits.incrementAndGet();
    }
    return value;
  }
360439
public V getService(K key) {
        ComponentContext ctx = context;

        if (ctx == null || key == null)
            return null;

        ConcurrentServiceReferenceElement<V> e = elementMap.get(key);
        if (e == null) {
            return null;
        } else {
            return e.getService(ctx);
        }
    }
671225
@SuppressWarnings("unchecked")
    public static <T> T poll(Object key) {
        try {
            return (T) CACHE.remove(key);
        } catch (ClassCastException e) {
            System.out.print("E/Cache: Can't use cached object: wrong type");
        }
        return null;
    }
1361216
private static int getEpisodeValue(Element eEpisode, String key) {
        int episodeValue;
        try {
            String value = DOMHelper.getValueFromElement(eEpisode, key);
            episodeValue = NumberUtils.toInt(value, 0);
        } catch (WebServiceException ex) {
            LOG.trace("Failed to read episode value", ex);
            episodeValue = 0;
        }

        return episodeValue;
    }
1372667
@Nullable
  public CloseableReference<CloseableImage> getCachedImage(@Nullable CacheKey cacheKey) {
    MemoryCache<CacheKey, CloseableImage> memoryCache = mBitmapMemoryCache;
    if (memoryCache == null || cacheKey == null) {
      return null;
    }
    CloseableReference<CloseableImage> closeableImage = memoryCache.get(cacheKey);
    if (closeableImage != null && !closeableImage.get().getQualityInfo().isOfFullQuality()) {
      closeableImage.close();
      return null;
    }
    return closeableImage;
  }
1219706
public AndroidElement get(String elementId) {
    AndroidElement element = cache.get(elementId);

    if (element instanceof AndroidNativeElement) {
      if (!ViewHierarchyAnalyzer.getDefaultInstance().isViewChieldOfCurrentRootView(
          ((AndroidNativeElement) element).getView())) {
        return null;
      }
    }
    return element;
  }
811063
@Override
    @SuppressWarnings("unchecked")
    public <T> T get(final Object key, final Class<T> type) {
        if (!cache.isEnabled()) {
            LOGGER.warn("Cache {} is disabled. Cannot get {} from cache", cache.getName(), key);
            return null;
        }

        Object value = getValue(key);
        if (value == null) {
            LOGGER.info("Cache miss. Get by key {} and type {} from cache {}", new Object[] { key, type, cache.getName() });
            return null;
        }

        if (value instanceof PertinentNegativeNull) {
            return null;
        }

        if (type != null && !type.isInstance(value)) {
            // in such case default Spring back end for EhCache throws IllegalStateException which interrupts
            // intercepted method invocation
            String msg = "Cached value is not of required type [" + type.getName() + "]: " + value;
            LOGGER.error(msg, new IllegalStateException(msg));
            return null;
        }

        LOGGER.info("Cache hit. Get by key {} and type {}  from cache {} value '{}'", new Object[] { key, type, cache.getName(), value });
        return (T) value;
    }
1098207
@Override
	public Promise get(String key) {
		try {
			int pos = partitionPosition(key, true);

			// Prefix is the name of the partition / region (eg.
			// "user" from the "user.name" cache key)
			String prefix = key.substring(0, pos);
			javax.cache.Cache<String, byte[]> partition = getPartition(prefix);
			if (partition != null) {
				byte[] bytes = partition.get(key.substring(pos + 1));
				if (bytes != null) {
					Tree root = serializer.read(bytes);
					Tree content = root.get(CONTENT);
					if (content != null) {
						return Promise.resolve(content);
					}
					return Promise.resolve(root);
				}
			}
		} catch (Throwable cause) {
			logger.warn("Unable to get data from JCache!", cause);
		}
		return Promise.resolve((Object) null);
	}
826286
public String getElementCollectionObjectName(Object rowKey, Object elementCollectionObject)
    {
        if (getElementCollectionCache().isEmpty() || getElementCollectionCache().get(rowKey) == null)
        {
            log.debug("No element collection object map found in cache for Row key " + rowKey);
            return null;
        }
        else
        {
            Map<Object, String> elementCollectionObjectMap = getElementCollectionCache().get(rowKey);
            String elementCollectionObjectName = elementCollectionObjectMap.get(elementCollectionObject);
            if (elementCollectionObjectName == null)
            {
                for (Object obj : elementCollectionObjectMap.keySet())
                {
                    if (DeepEquals.deepEquals(elementCollectionObject, obj))
                    {
                        elementCollectionObjectName = elementCollectionObjectMap.get(obj);
                        break;
                    }
                }
            }

            if (elementCollectionObjectName == null)
            {
                log.debug("No element collection object name found in cache for object:" + elementCollectionObject);
                return null;
            }
            else
            {
                return elementCollectionObjectName;
            }
        }
    }
514000
public synchronized CacheObject get(Object key)
	{
		final CacheObject o = (CacheObject) map.get(key);
		if (o != null) {
			tree.remove(o);
			updateAccess(o);
			tree.put(o, o);
			++hits;
		}
		else
			++misses;
		return o;
	}
877413
@Override
    public INDArray get(T key) {
        try {
            if (emulateIsAbsent)
                lock.readLock().lock();

            if (containsKey(key)) {
                INDArray result = compressedEntries.get(key);

                // TODO: we don't save decompressed entries here, but something like LRU might be good idea
                return compressor.decompress(result);
            } else {
                return null;
            }
        } finally {
            if (emulateIsAbsent)
                lock.readLock().unlock();
        }
    }
360061
public E get (Comparable<?> key)
    {
        // determine where we'll be adding the new element
        int eidx = ArrayUtil.binarySearch(
            _entries, 0, _size, new SimpleEntry<Comparable<?>>(key), ENTRY_COMP);
        return (eidx < 0) ? null : _entries[eidx];
    }
428210
public synchronized boolean containsKey(CacheKey key) {
    Preconditions.checkNotNull(key);
    if (!mMap.containsKey(key)) {
      return false;
    }
    EncodedImage storedEncodedImage = mMap.get(key);
    synchronized (storedEncodedImage) {
      if (!EncodedImage.isValid(storedEncodedImage)) {
        // Reference is not valid, this means that someone cleared reference while it was still in
        // use. Log error
        // TODO: 3697790
        mMap.remove(key);
        FLog.w(
            TAG,
            "Found closed reference %d for key %s (%d)",
            System.identityHashCode(storedEncodedImage),
            key.getUriString(),
            System.identityHashCode(key));
        return false;
      }
      return true;
    }
  }