You are here

protected function S3fsStream::_read_cache in S3 File System 8.2

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 S3fsStream::_read_cache()
S3fsStream::getExternalUrl in src/StreamWrapper/S3fsStream.php
Returns a web accessible URL for the resource.
S3fsStream::mkdir in src/StreamWrapper/S3fsStream.php
Support for mkdir().
S3fsStream::rename in src/StreamWrapper/S3fsStream.php
Support for rename().
S3fsStream::stream_open in src/StreamWrapper/S3fsStream.php
Support for fopen(), file_get_contents(), file_put_contents() etc.
S3fsStream::_s3fs_get_object in src/StreamWrapper/S3fsStream.php
Try to fetch an object from the metadata cache.

File

src/StreamWrapper/S3fsStream.php, line 1250

Class

S3fsStream
Defines a Drupal s3fs (s3fs://) stream wrapper class.

Namespace

Drupal\s3fs\StreamWrapper

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);
  }
  else {
    if (strpos($uri, 'private:///') === 0) {
      $uri = preg_replace('^private://[/]+^', 'private://', $uri);
    }
  }

  //@todo: Cache Implementation
  $record = \Drupal::database()
    ->select('s3fs_file', 's')
    ->fields('s')
    ->condition('uri', $uri, '=')
    ->execute()
    ->fetchAssoc();
  return $record ? $record : FALSE;
}