You are here

class AcquiaPurgeStateStorageDisk in Acquia Purge 7

File backed state storage.

Hierarchy

Expanded class hierarchy of AcquiaPurgeStateStorageDisk

File

lib/state/AcquiaPurgeStateStorageDisk.php, line 11
Contains AcquiaPurgeStateStorageDisk.

View source
class AcquiaPurgeStateStorageDisk extends AcquiaPurgeStateStorageBase {

  /**
   * The raw payload to compare changes against.
   *
   * @var string
   */
  protected $raw = '';

  /**
   * The URI identifier to the file (on disk) to store state data in.
   *
   * @var string
   */
  protected $uri;

  /**
   * Construct AcquiaPurgeStateStorageDisk.
   *
   * @param string $uri
   *   The URI identifier to the file (on disk) to store state data in.
   */
  public function __construct($uri) {
    $this->uri = $uri;
    if (file_exists($this->uri)) {
      if ($buffer = file_get_contents($this->uri)) {
        if (parent::__construct(unserialize($buffer))) {
          $this->raw = $buffer;
        }
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public function commit() {
    if (!$this->commit) {
      return;
    }
    else {
      $this->commit = FALSE;
    }
    $raw_new = serialize($this->buffer);
    if ($raw_new !== $this->raw) {
      $this->raw = $raw_new;
      file_put_contents($this->uri, $this->raw);
    }
  }

  /**
   * {@inheritdoc}
   */
  public function wipe() {
    parent::wipe();
    $this->raw = '';
    if (file_exists($this->uri)) {
      drupal_unlink($this->uri);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AcquiaPurgeStateStorageBase::$buffer protected property The payload buffer which gets synchronized with memcached.
AcquiaPurgeStateStorageBase::$commit protected property Indicates if ::commit() has been registered to be called at shutdown.
AcquiaPurgeStateStorageBase::$items protected property Item instances.
AcquiaPurgeStateStorageBase::get public function Retrieve the object named $key. Overrides AcquiaPurgeStateStorageInterface::get
AcquiaPurgeStateStorageBase::getCounter public function Retrieve a counter object named $key. Overrides AcquiaPurgeStateStorageInterface::getCounter
AcquiaPurgeStateStorageBase::set public function Store the state item in state item storage. Overrides AcquiaPurgeStateStorageInterface::set
AcquiaPurgeStateStorageDisk::$raw protected property The raw payload to compare changes against.
AcquiaPurgeStateStorageDisk::$uri protected property The URI identifier to the file (on disk) to store state data in.
AcquiaPurgeStateStorageDisk::commit public function Commit the state data to its persistent storage location. Overrides AcquiaPurgeStateStorageInterface::commit
AcquiaPurgeStateStorageDisk::wipe public function Wipe all state data. Overrides AcquiaPurgeStateStorageBase::wipe
AcquiaPurgeStateStorageDisk::__construct public function Construct AcquiaPurgeStateStorageDisk. Overrides AcquiaPurgeStateStorageBase::__construct