Skip to content

lcache wildcard prefix clear removes all cache entries for the bin #1

Open
@LionsAd

Description

@LionsAd
diff --git a/sites/all/modules/contrib/lcache/lcache.cache.inc b/sites/all/modules/contrib/lcache/lcache.cache.inc
index c789454..daa1976 100644
--- a/sites/all/modules/contrib/lcache/lcache.cache.inc
+++ b/sites/all/modules/contrib/lcache/lcache.cache.inc
@@ -63,8 +63,8 @@ class LCache implements DrupalCacheInterface {
     $this->integrated = new \LCache\Integrated($l1, $l2, 100);
   }
 
-  protected function getAddress($cid=NULL) {
-    return new \LCache\Address($this->bin, $cid);
+  protected function getAddress($cid=NULL, $wildcard = FALSE) {
+    return new \LCache\Address($this->bin, $cid, $wildcard);
   }
 
   /**
@@ -125,7 +125,7 @@ class LCache implements DrupalCacheInterface {
       $this->integrated->collectGarbage();
     }
     else {
-      if ($wildcard) {
+      if ($wildcard && $cid == '*') {
         $address = $this->getAddress();
         $this->integrated->delete($address);
       }
@@ -136,7 +136,7 @@ class LCache implements DrupalCacheInterface {
         }
       }
       else {
-        $address = $this->getAddress($cid);
+        $address = $this->getAddress($cid, $wildcard);
         $this->integrated->delete($address);
       }
     }
diff --git a/sites/all/modules/contrib/lcache/vendor/lcache/lcache/src/Address.php b/sites/all/modules/contrib/lcache/vendor/lcache/lcache/src/Address.php
index efe5d94..dbb9680 100644
--- a/sites/all/modules/contrib/lcache/vendor/lcache/lcache/src/Address.php
+++ b/sites/all/modules/contrib/lcache/vendor/lcache/lcache/src/Address.php
@@ -12,18 +12,22 @@ final class Address implements \Serializable
     protected $bin;
     /** @var string|null */
     protected $key;
+    /** @var bool */
+    protected $wildcard = false;
 
     /**
      * Address constructor.
      *
      * @param string|null $bin
      * @param string|null $key
+     * @param bool $woldcard
      */
-    public function __construct($bin = null, $key = null)
+    public function __construct($bin = null, $key = null, $wildcard = false)
     {
         assert(!is_null($bin) || is_null($key));
         $this->bin = $bin;
         $this->key = $key;
+        $this->wildcard = $wildcard;
     }
 
     /**
@@ -50,7 +54,7 @@ final class Address implements \Serializable
      */
     public function isEntireBin()
     {
-        return is_null($this->key);
+        return is_null($this->key) || $this->wildcard;
     }
 
     /**

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions