diff --git a/modules/quant_purger/config/schema/quant_purger.schema.yml b/modules/quant_purger/config/schema/quant_purger.schema.yml index 887cf0d5..94c10443 100644 --- a/modules/quant_purger/config/schema/quant_purger.schema.yml +++ b/modules/quant_purger/config/schema/quant_purger.schema.yml @@ -9,7 +9,7 @@ quant_purger.settings: translatable: false sequence: type: string - label: 'String that cannot be present in the ccache tag.' + label: 'String that cannot be present in the cache tag.' translatable: false path_blacklist: label: 'A list of string patterns that will not get queued.' diff --git a/modules/quant_purger/src/Entity/Hash.php b/modules/quant_purger/src/Entity/Hash.php new file mode 100644 index 00000000..db35698f --- /dev/null +++ b/modules/quant_purger/src/Entity/Hash.php @@ -0,0 +1,70 @@ + 4) { + $hashes[] = self::hashInput($tag, 4); + } + else { + $hashes[] = $tag; + } + } + return $hashes; + } + + /** + * Create a unique hash that identifies this site. + * + * @param string $site_name + * The identifier of the site on Acquia Cloud. + * @param string $site_path + * The path of the site, e.g. 'site/default' or 'site/database_a'. + * + * @return string + * Cryptographic hash that's long enough to be unique. + */ + public static function siteIdentifier($site_name, $site_path) { + return self::hashInput($site_name . $site_path, 16); + } + +} diff --git a/modules/quant_purger/src/Plugin/Purge/TagsHeader/CacheTagsHeaderValue.php b/modules/quant_purger/src/Plugin/Purge/TagsHeader/CacheTagsHeaderValue.php new file mode 100644 index 00000000..229f93dd --- /dev/null +++ b/modules/quant_purger/src/Plugin/Purge/TagsHeader/CacheTagsHeaderValue.php @@ -0,0 +1,68 @@ +tags = array_unique($tags); + $this->tagsHashed = array_unique($tags_hashed); + } + + /** + * Generate the header value for a cache tags header. + * + * @return string + * String representation of the cache tags for use on headers. + */ + public function __toString() { + return implode(self::SEPARATOR, $this->tagsHashed); + } + + /** + * Get an associative array mapping keys. + * + * @return array + * Associative mapping original and hashed cache tags. + */ + public function getTagsMap() { + return array_combine($this->tags, $this->tagsHashed); + } + +} diff --git a/modules/quant_purger/src/Plugin/Purge/TagsHeader/QuantCacheTagsHeader.php b/modules/quant_purger/src/Plugin/Purge/TagsHeader/QuantCacheTagsHeader.php new file mode 100644 index 00000000..7fc09a38 --- /dev/null +++ b/modules/quant_purger/src/Plugin/Purge/TagsHeader/QuantCacheTagsHeader.php @@ -0,0 +1,26 @@ +