Get data back out of the cache as a ByteStream.

@param string                $nsKey
@param string                $itemKey
@param Swift_InputByteStream $is      to write the data to
482472
public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is)
    {
        $this->prepareCache($nsKey);
        $is->write($this->getString($nsKey, $itemKey));
    }
71817
public static void write(final PublicKey publicKey, final @NonNull OutputStream outputStream)
		throws IOException
	{
		final byte[] publicKeyBytes = publicKey.getEncoded();
		final X509EncodedKeySpec keySpec = new X509EncodedKeySpec(publicKeyBytes);
		outputStream.write(keySpec.getEncoded());
		outputStream.close();
	}
610099
public function setMainResponseKey($mainResponseKey, $isList = false)
    {
        $this->mainResponseKey = $mainResponseKey;
        $this->isList = $isList;
        if (!empty($this->response)) {
            $this->response = $this->simplifyResponse($this->response);
        }
        return $this;
    }
903600
private function generateItems(RequestInterface $request, $itemsKey, array $data)
    {
        foreach ($data[$itemsKey] as $item) {
            yield $item;
        }

        $queryHelper = new QueryHelper($request->getUri()->getQuery());
        $maxResults = $queryHelper->getValue('MaxResults');

        if (is_numeric($maxResults) && $maxResults >= 0) {
            $maxResults -= \count($data[$itemsKey]);
        } else {
            $maxResults = null;
        }

        while (isset($data['NextPageToken']) && (null === $maxResults || $maxResults > 0)) {
            $request = $queryHelper
                ->setValue('PageToken', $data['NextPageToken'])
                ->setValue('MaxResults', $maxResults)
                ->applyToRequest($request);

            $data = $this->request($request);

            foreach ($data[$itemsKey] as $item) {
                yield $item;
            }

            if (null !== $maxResults) {
                $maxResults -= \count($data[$itemsKey]);
            }
        }
    }
1367430
public function getString($nsKey, $itemKey)
    {
        $this->prepareCache($nsKey);
        if ($this->hasKey($nsKey, $itemKey)) {
            $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_START);
            $str = '';
            while (!feof($fp) && false !== $bytes = fread($fp, 8192)) {
                $str .= $bytes;
            }
            $this->freeHandle($nsKey, $itemKey);

            return $str;
        }
    }
19162
public void writeLock(EntityKey key, int timeout) {
		ReadWriteLock lock = getLock( key );
		Lock writeLock = lock.writeLock();
		acquireLock( key, timeout, writeLock );
	}
1257037
public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode)
    {
        $this->prepareCache($nsKey);
        switch ($mode) {
            case self::MODE_WRITE:
                $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_START);
                break;
            case self::MODE_APPEND:
                $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_END);
                break;
            default:
                throw new Swift_SwiftException(
                    'Invalid mode ['.$mode.'] used to set nsKey='.
                    $nsKey.', itemKey='.$itemKey
                    );
                break;
        }
        while (false !== $bytes = $os->read(8192)) {
            fwrite($fp, $bytes);
        }
        $this->freeHandle($nsKey, $itemKey);
    }
1011412
@Override
    public synchronized Entry get(String key) {
        CacheHeader entry = mEntries.get(key);
        // if the entry does not exist, return.
        if (entry == null) {
            return null;
        }

        File file = getFileForKey(key);
        CountingInputStream cis = null;
        try {
            cis = new CountingInputStream(new BufferedInputStream(new FileInputStream(file)));
            CacheHeader.readHeader(cis); // eat header
            byte[] data = streamToBytes(cis, (int) (file.length() - cis.bytesRead));
            return entry.toCacheEntry(data);
        } catch (IOException e) {
            //todo add queue markers
            JusLog.log(file.getAbsolutePath() + ": " + e.toString());
            remove(key);
            return null;
        } catch (NegativeArraySizeException e) {
            JusLog.log(file.getAbsolutePath() + ": " + e.toString());
            remove(key);
            return null;
        } finally {
            if (cis != null) {
                try {
                    cis.close();
                } catch (IOException ioe) {
                    return null;
                }
            }
        }
    }
466515
private function saveDeferred($key, $data, $expiresAfter = null, $tags = [])
    {
        $item = $this->cache->getItem($key);
        $item->set($data);
        $item->expiresAfter($expiresAfter);

        if (0 !== \count($tags)) {
            $item->tag($tags);
        }

        return $this->cache->saveDeferred($item);
    }
1054582
@Override
  public FSDataOutputStream createObject(String objName, String contentType,
      Map<String, String> metadata, Statistics statistics) throws IOException {
    final URL url = new URL(mJossAccount.getAccessURL() + "/" + getURLEncodedObjName(objName));
    LOG.debug("PUT {}. Content-Type : {}", url.toString(), contentType);

    // When overwriting an object, cached metadata will be outdated
    String cachedName = getObjName(container + "/", objName);
    objectCache.remove(cachedName);

    try {
      final OutputStream sos;
      if (nonStreamingUpload) {
        sos = new SwiftNoStreamingOutputStream(mJossAccount, url, contentType,
            metadata, swiftConnectionManager, this);
      } else {
        sos = new SwiftOutputStream(mJossAccount, url, contentType,
            metadata, swiftConnectionManager);
      }
      return new FSDataOutputStream(sos, statistics);
    } catch (IOException e) {
      LOG.error(e.getMessage());
      throw e;
    }
  }
1172888
public function clearAll($nsKey)
    {
        if (array_key_exists($nsKey, $this->keys)) {
            foreach ($this->keys[$nsKey] as $itemKey => $null) {
                $this->clearKey($nsKey, $itemKey);
            }
            if (is_dir($this->path.'/'.$nsKey)) {
                rmdir($this->path.'/'.$nsKey);
            }
            unset($this->keys[$nsKey]);
        }
    }
2791
public InputType getElementTypeUsingKey(String itemKey) {
    String type = this.getDataType().get(itemKey).getAsString().toUpperCase();
    return InputType.valueOf(type);
  }
910898
protected boolean isItemAccepted(byte[] key) {
        boolean entryAccepted = false;
        if (!fetchOrphaned) {
            if (isKeyNeeded(key)) {
                entryAccepted = true;
            }
        } else {
            if (!StoreRoutingPlan.checkKeyBelongsToNode(key, nodeId, initialCluster, storeDef)) {
                entryAccepted = true;
            }
        }
        return entryAccepted;
    }
669009
@Override
    public void coreUpdateCatalog(final long timestamp, final boolean isStreamUpdate, final String catalogDiffs) throws EEException {
        int result = ExecutionEngine.ERRORCODE_ERROR;

        try {
            final byte catalogBytes[] = catalogDiffs.getBytes("UTF-8");
            verifyDataCapacity(catalogBytes.length + 100);
            m_data.clear();
            m_data.putInt(Commands.UpdateCatalog.m_id);
            m_data.putLong(timestamp);
            m_data.putInt(isStreamUpdate ? 1 : 0);
            m_data.put(catalogBytes);
            m_data.put((byte)'\0');
        } catch (final UnsupportedEncodingException ex) {
            Logger.getLogger(ExecutionEngineIPC.class.getName()).log(
                    Level.SEVERE, null, ex);
        }

        try {
            m_data.flip();
            m_connection.write();
            result = m_connection.readStatusByte();
        } catch (final IOException e) {
            System.out.println("Exception: " + e.getMessage());
            throw new RuntimeException(e);
        }
        checkErrorCode(result);
    }
527051
@VisibleForTesting
  static void writeBytesToStream(byte[] bytes, final OutputStream outputStream)
      throws IOException {
    new ByteSink() {
      @Override
      public OutputStream openStream() {
        return outputStream;
      }
    }.write(bytes);
  }
1173933
public static SObject of(String key, InputStream is, Map<String, String> conf) {
        SObject sobj = of(key, is);
        sobj.setAttributes(conf);
        return sobj;
    }
1021514
public static function EncryptByteStream ($byte, $key, $options = []) {
		$options['module'] = \MCRYPT_MODE_CFB;
		return static::Encrypt($byte, $key, $options);
	}