You are here

class DrupalFlysystemCache in Flysystem 7

An adapter that allows Flysystem to use Drupal's cache system.

Hierarchy

  • class \Drupal\flysystem\DrupalFlysystemCache extends \League\Flysystem\Cached\Storage\AbstractCache

Expanded class hierarchy of DrupalFlysystemCache

1 file declares its use of DrupalFlysystemCache
FlysystemFactory.php in src/FlysystemFactory.php
Contains \Drupal\flysystem\FlysystemFactory.

File

src/DrupalFlysystemCache.php, line 15
Contains DrupalFlysystemCache.

Namespace

Drupal\flysystem
View source
class DrupalFlysystemCache extends AbstractCache {

  /**
   * The cache key.
   *
   * @var string
   */
  protected $key;

  /**
   * Constructs a DrupalFlysystemCache object.
   *
   * @param string $key
   *   The cache key to use.
   */
  public function __construct($key) {
    $this->key = $key;
  }

  /**
   * {@inheritdoc}
   */
  public function load() {
    if ($cache = cache_get($this->key)) {
      $this->cache = $cache->data[0];
      $this->complete = $cache->data[1];
    }
  }

  /**
   * {@inheritdoc}
   */
  public function save() {
    $cleaned = $this
      ->cleanContents($this->cache);
    cache_set($this->key, array(
      $cleaned,
      $this->complete,
    ));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DrupalFlysystemCache::$key protected property The cache key.
DrupalFlysystemCache::load public function
DrupalFlysystemCache::save public function
DrupalFlysystemCache::__construct public function Constructs a DrupalFlysystemCache object.