You are here

protected function S3fsStream::_delete_cache in S3 File System 8.2

Delete an object's metadata from the cache.

Parameters

mixed $uri: A string (or array of strings) containing the URI(s) of the object(s) to be deleted.

Throws

Exceptions which occur in the database call will percolate.

1 call to S3fsStream::_delete_cache()
S3fsStream::unlink in src/StreamWrapper/S3fsStream.php
Support for unlink().

File

src/StreamWrapper/S3fsStream.php, line 1332

Class

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

Namespace

Drupal\s3fs\StreamWrapper

Code

protected function _delete_cache($uri) {
  $this
    ->_debug("_delete_cache({$uri}) called.", TRUE);
  if (!is_array($uri)) {
    $uri = [
      $uri,
    ];
  }

  // Build an OR query to delete all the URIs at once.
  $delete_query = \Drupal::database()
    ->delete('s3fs_file');
  $or = $delete_query
    ->orConditionGroup();
  foreach ($uri as $u) {
    $or
      ->condition('uri', $u, '=');

    // Clear this URI from the Drupal cache.
    // @todo in cache issue
    // $cid = S3FS_CACHE_PREFIX . $u;
    // $cache = \Drupal::cache('S3FS_CACHE_BIN');
    // $cache->delete($cid);
  }
  $delete_query
    ->condition($or);
  return $delete_query
    ->execute();
}