You are here

protected function S3fsStreamWrapper::_read_cache in S3 File System 7.2

Same name and namespace in other branches
  1. 7.3 S3fsStreamWrapper.inc \S3fsStreamWrapper::_read_cache()
  2. 7 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 An array of metadata if the $uri is in the cache. Otherwise, FALSE.

5 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
Support for rename().
S3fsStreamWrapper::stream_open in ./S3fsStreamWrapper.inc
Support for fopen(), file_get_contents(), file_put_contents() etc.
S3fsStreamWrapper::_s3fs_get_object in ./S3fsStreamWrapper.inc
Try to fetch an object from the metadata cache.

File

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

Class

S3fsStreamWrapper
The stream wrapper class.

Code

protected function _read_cache($uri) {
  $this
    ->_debug("_read_cache({$uri}) called.", TRUE);

  // 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;
}