You are here

protected function S3fsStreamWrapper::_read_cache in S3 File System 7.3

Same name and namespace in other branches
  1. 7 S3fsStreamWrapper.inc \S3fsStreamWrapper::_read_cache()
  2. 7.2 S3fsStreamWrapper.inc \S3fsStreamWrapper::_read_cache()

Fetch an object from the file metadata cache table.

Parameters

string $uri: The uri of the resource to check.

Return value

array|bool An array of metadata if the $uri is in the cache. Otherwise, FALSE.

4 calls to S3fsStreamWrapper::_read_cache()
S3fsStreamWrapper::getExternalUrl in ./S3fsStreamWrapper.inc
Returns a web accessible URL for the resource.
S3fsStreamWrapper::mkdir in ./S3fsStreamWrapper.inc
Support for mkdir().
S3fsStreamWrapper::rename in ./S3fsStreamWrapper.inc
S3fsStreamWrapper::_s3fs_get_object in ./S3fsStreamWrapper.inc
Try to fetch an object from the metadata cache.

File

./S3fsStreamWrapper.inc, line 1018
Drupal stream wrapper implementation for S3 File System.

Class

S3fsStreamWrapper
The stream wrapper class.

Code

protected function _read_cache($uri) {

  // Since public:///blah.jpg and public://blah.jpg refer to the same file
  // (a file named blah.jpg at the root of the file system), we'll sometimes
  // receive files with a /// in their uri. This messes with our caching
  // scheme, though, so we need to remove the extra /.
  if (strpos($uri, 'public:///') === 0) {
    $uri = preg_replace('^public://[/]+^', 'public://', $uri);
  }
  elseif (strpos($uri, 'private:///') === 0) {
    $uri = preg_replace('^private://[/]+^', 'private://', $uri);
  }
  $record = db_select('s3fs_file', 's')
    ->fields('s')
    ->condition('uri', $uri, '=')
    ->execute()
    ->fetchAssoc();
  return $record ? $record : FALSE;
}