Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / memcache / src / Invalidator / MemcacheTimestampInvalidator.php
diff --git a/web/modules/contrib/memcache/src/Invalidator/MemcacheTimestampInvalidator.php b/web/modules/contrib/memcache/src/Invalidator/MemcacheTimestampInvalidator.php
new file mode 100644 (file)
index 0000000..56e8f1c
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+
+namespace Drupal\memcache\Invalidator;
+
+use Drupal\memcache\Driver\MemcacheDriverFactory;
+
+/**
+ * Class MemcacheTimestampInvalidator.
+ */
+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);
+  }
+
+}