Skip to content
Snippets Groups Projects
Verified Commit 51f16296 authored by Alberto Paderno's avatar Alberto Paderno
Browse files

Issue #3472908: Define class constants for the regular expressions to use to...

Issue #3472908: Define class constants for the regular expressions to use to remove APCu keys used for cache and locks
parent aaf29697
No related branches found
No related tags found
1 merge request!81Issue #3472908: Define class constants for the regular expressions to use to remove APCu keys used for cache and locks
Pipeline #277394 passed
......@@ -146,8 +146,8 @@ function apc_update_7201(): void {
*/
function apc_uninstall(): void {
if (extension_loaded('apcu') && apcu_enabled()) {
$cache_iterator = new APCUIterator('/^apc_cache::[a-zA-Z0-9-_]{40,46}::[0-9a-f]{2,}/', APC_ITER_KEY);
$lock_iterator = new APCUIterator('/^apc_lock::[a-zA-Z0-9-_]{40,46}/', APC_ITER_KEY);
$cache_iterator = new APCUIterator(ApcCache::CACHE_KEYS_REGEXP, APC_ITER_KEY);
$lock_iterator = new APCUIterator(ApcLock::LOCK_KEYS_REGEXP, APC_ITER_KEY);
// Delete all the APCu keys used by the module.
apcu_delete($cache_iterator);
......
......@@ -15,6 +15,13 @@
*/
class ApcCache implements DrupalCacheInterface {
/**
* The regular expression to delete the APCu keys used for cache values.
*
* @var string
*/
public const CACHE_KEYS_REGEXP = '/^apc_cache::[a-zA-Z0-9-_]{40,46}::[0-9a-f]{2,}/';
/**
* The list of all the operations done to the cache.
*
......
......@@ -16,6 +16,13 @@
*/
class ApcLock {
/**
* The regular expression to delete the APCu keys used for lock values.
*
* @var string
*/
public const LOCK_KEYS_REGEXP = '/^apc_lock::[a-zA-Z0-9-_]{40,46}/';
/**
* The locks acquired in the current request.
*
......
......@@ -75,7 +75,7 @@ function apc_admin_form_system_performance_settings_alter(&$form, &$form_state):
*/
function apc_admin_clear_apcu_cache(): void {
if (extension_loaded('apcu') && apcu_enabled()) {
$iterator = new APCUIterator("/^apc_cache::[a-zA-Z0-9-_]{20,}::[a-zA-Z0-9-_]{20,}/", APC_ITER_KEY);
$iterator = new APCUIterator(ApcCache::CACHE_KEYS_REGEXP, APC_ITER_KEY);
if (apcu_delete($iterator)) {
drupal_set_message(t('The APCu cache has been cleared.'));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment