Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / memcache / src / Invalidator / MemcacheTimestampInvalidator.php
1 <?php
2
3 namespace Drupal\memcache\Invalidator;
4
5 use Drupal\memcache\Driver\MemcacheDriverFactory;
6
7 /**
8  * Class MemcacheTimestampInvalidator.
9  */
10 class MemcacheTimestampInvalidator extends TimestampInvalidatorBase {
11
12   /**
13    * A Memcache object.
14    *
15    * @var \Drupal\memcache\DrupalMemcacheInterface
16    */
17   protected $memcache;
18
19   /**
20    * MemcacheTimestampInvalidator constructor.
21    *
22    * @param \Drupal\memcache\Driver\MemcacheDriverFactory $memcache_factory
23    *   Factory class for creation of Memcache objects.
24    * @param string $bin
25    *   Memcache bin to store the timestamps in.
26    * @param float $tolerance
27    *   Allowed clock skew between servers, in decimal seconds.
28    */
29   public function __construct(MemcacheDriverFactory $memcache_factory, $bin, $tolerance = 0.001) {
30     parent::__construct($tolerance);
31     $this->memcache = $memcache_factory->get($bin);
32   }
33
34   /**
35    * {@inheritdoc}
36    */
37   public function invalidateTimestamp($tag) {
38     return $this->markAsOutdated($tag);
39   }
40
41   /**
42    * {@inheritdoc}
43    */
44   public function getLastInvalidationTimestamp($tag) {
45     return $this->memcache->get($tag);
46   }
47
48   /**
49    * {@inheritdoc}
50    */
51   public function getLastInvalidationTimestamps(array $tags) {
52     return $this->memcache->getMulti($tags);
53   }
54
55   /**
56    * {@inheritdoc}
57    */
58   protected function writeTimestamp($tag, $timestamp) {
59     return $this->memcache->set($tag, $timestamp);
60   }
61
62 }