You are here

class MemcacheTimestampInvalidator in Memcache API and Integration 8.2

Class MemcacheTimestampInvalidator.

Hierarchy

Expanded class hierarchy of MemcacheTimestampInvalidator

2 string references to 'MemcacheTimestampInvalidator'
example.services.yml in ./example.services.yml
example.services.yml
memcache.services.yml in ./memcache.services.yml
memcache.services.yml
2 services use MemcacheTimestampInvalidator
memcache.timestamp.invalidator.bin in ./memcache.services.yml
Drupal\memcache\Invalidator\MemcacheTimestampInvalidator
memcache.timestamp.invalidator.tag in ./example.services.yml
Drupal\memcache\Invalidator\MemcacheTimestampInvalidator

File

src/Invalidator/MemcacheTimestampInvalidator.php, line 10

Namespace

Drupal\memcache\Invalidator
View source
class MemcacheTimestampInvalidator extends TimestampInvalidatorBase {

  /**
   * A Memcache object.
   *
   * @var \Drupal\memcache\DrupalMemcacheInterface
   */
  protected $memcache;

  /**
   * MemcacheTimestampInvalidator constructor.
   *
   * @param \Drupal\memcache\Driver\MemcacheDriverFactory $memcache_factory
   *   Factory class for creation of Memcache objects.
   * @param string $bin
   *   Memcache bin to store the timestamps in.
   * @param float $tolerance
   *   Allowed clock skew between servers, in decimal seconds.
   */
  public function __construct(MemcacheDriverFactory $memcache_factory, $bin, $tolerance = 0.001) {
    parent::__construct($tolerance);
    $this->memcache = $memcache_factory
      ->get($bin);
  }

  /**
   * {@inheritdoc}
   */
  public function invalidateTimestamp($tag) {
    return $this
      ->markAsOutdated($tag);
  }

  /**
   * {@inheritdoc}
   */
  public function getLastInvalidationTimestamp($tag) {
    return $this->memcache
      ->get($tag);
  }

  /**
   * {@inheritdoc}
   */
  public function getLastInvalidationTimestamps(array $tags) {
    return $this->memcache
      ->getMulti($tags);
  }

  /**
   * {@inheritdoc}
   */
  protected function writeTimestamp($tag, $timestamp) {
    return $this->memcache
      ->set($tag, $timestamp);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MemcacheTimestampInvalidator::$memcache protected property A Memcache object.
MemcacheTimestampInvalidator::getLastInvalidationTimestamp public function Get the last invalidation timestamp of a tag. Overrides TimestampInvalidatorInterface::getLastInvalidationTimestamp
MemcacheTimestampInvalidator::getLastInvalidationTimestamps public function Get the last invalidation timestamps of a set of tags. Overrides TimestampInvalidatorBase::getLastInvalidationTimestamps
MemcacheTimestampInvalidator::invalidateTimestamp public function Invalidate the timestamp of a tag. Overrides TimestampInvalidatorBase::invalidateTimestamp
MemcacheTimestampInvalidator::writeTimestamp protected function Write an updated timestamp for a tag to the backend. Overrides TimestampInvalidatorBase::writeTimestamp
MemcacheTimestampInvalidator::__construct public function MemcacheTimestampInvalidator constructor. Overrides TimestampInvalidatorBase::__construct
TimestampInvalidatorBase::$tolerance protected property Allowed timestamp slop.
TimestampInvalidatorBase::getCurrentTimestamp public function Get the current timestamp, optionally offset by a number. Overrides TimestampInvalidatorInterface::getCurrentTimestamp
TimestampInvalidatorBase::markAsOutdated protected function Mark a tag as outdated.