summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Skovgaard Gielfeldt2012-11-18 08:01:54 (GMT)
committer Thomas Skovgaard Gielfeldt2012-11-18 08:01:54 (GMT)
commit4552fc3572a82b37ea4cd6aa6b08e716835a6e3e (patch)
tree93c07a4edebc79b56f23934c72eb57235007462e
parent8cefd80eb64e5818621624967202a4c17e1a83c8 (diff)
Issue #1842924 by gielfeldt - Delete cache_graceful variables when uninstalling6.x-1.76.x-1.x
Removed deprecated file.
-rw-r--r--CacheGraceful.class.php126
-rw-r--r--README.txt5
-rw-r--r--cache_graceful.install18
3 files changed, 18 insertions, 131 deletions
diff --git a/CacheGraceful.class.php b/CacheGraceful.class.php
deleted file mode 100644
index dbb32b7..0000000
--- a/CacheGraceful.class.php
+++ /dev/null
@@ -1,126 +0,0 @@
-<?php
-
-/**
- * Default cache implementation.
- *
- * This is Drupal's default cache implementation. It uses the database to store
- * cached data. Each cache bin corresponds to a database table by the same name.
- */
-class CacheGraceful extends DrupalDatabaseCache {
- protected $locks = array();
-
- protected function prepareItem($cache) {
- if ($this->hasExpired($cache)) {
- return FALSE;
- }
- return parent::prepareItem($cache);
- }
-
- function set($cid, $data, $expire = CACHE_PERMANENT) {
- if (empty($cid)) return;
- parent::set($cid, $data, $expire);
- if (!empty($this->locks[$cid])) {
- unset($this->locks[$cid]);
- try {
- lock_release("cache:$this->bin:$cid");
- }
- catch (Exception $e) {
- // Error releasing lock
- }
- }
- }
-
- /**
- * Check if object has expired
- * @fixme Smelly code: Also sets a lock. Doesn't quite fit the name hasExpired().
- */
- function hasExpired($cache) {
- if (empty($cache->cid)) return TRUE;
-
- if ($cache->expire > 0 && $cache->expire < time()) {
- try {
- // Expired
- if (lock_acquire("cache:$this->bin:$cache->cid")) {
- // Got lock, assuming caller will fill cache.
- $this->locks[$cache->cid] = TRUE;;
- return TRUE;
- }
- else {
- // Stale
- return FALSE;
- }
- }
- catch (Exception $e) {
- // Couldn't lock
- return TRUE;
- }
- }
- }
-
- function clear($cid = NULL, $wildcard = FALSE) {
- global $user;
-
- if (empty($cid)) {
- if (variable_get('cache_lifetime', 0)) {
- // We store the time in the current user's $user->cache variable which
- // will be saved into the sessions bin by _drupal_session_write(). We then
- // simulate that the cache was flushed for this user by not returning
- // cached data that was cached before the timestamp.
- $user->cache = REQUEST_TIME;
-
- $cache_flush = variable_get('cache_flush_' . $this->bin, 0);
- if ($cache_flush == 0) {
- // This is the first request to clear the cache, start a timer.
- variable_set('cache_flush_' . $this->bin, REQUEST_TIME);
- }
- elseif (REQUEST_TIME > ($cache_flush + variable_get('cache_lifetime', 0))) {
- // Clear the cache for everyone, cache_lifetime seconds have
- // passed since the first request to clear the cache.
- db_delete($this->bin)
- ->condition('expire', CACHE_PERMANENT, '<>')
- ->condition('expire', REQUEST_TIME, '<')
- ->execute();
- variable_set('cache_flush_' . $this->bin, 0);
- }
- }
- else {
- // No minimum cache lifetime, flush all temporary cache entries now.
- db_delete($this->bin)
- ->condition('expire', CACHE_PERMANENT, '<>')
- ->condition('expire', REQUEST_TIME, '<')
- ->execute();
- }
- }
- else {
- if ($wildcard) {
- if ($cid == '*') {
- db_update($this->bin)
- ->fields(array('expire' => REQUEST_TIME))
- ->execute();
- }
- else {
- db_update($this->bin)
- ->fields(array('expire' => REQUEST_TIME))
- ->condition('cid', db_like($cid) . '%', 'LIKE')
- ->execute();
- }
- }
- elseif (is_array($cid)) {
- // Delete in chunks when a large array is passed.
- do {
- db_update($this->bin)
- ->fields(array('expire' => REQUEST_TIME))
- ->condition('cid', array_splice($cid, 0, 1000), 'IN')
- ->execute();
- }
- while (count($cid));
- }
- else {
- db_update($this->bin)
- ->fields(array('expire' => REQUEST_TIME))
- ->condition('cid', $cid)
- ->execute();
- }
- }
- }
-}
diff --git a/README.txt b/README.txt
index dcc3282..7f2a144 100644
--- a/README.txt
+++ b/README.txt
@@ -1,10 +1,5 @@
To use graceful cache for entire system use the following in your settings file:
-Plain Drupal 6 style:
-include './includes/cache.inc';
-include './sites/all/modules/cache_graceful/CacheGraceful.class.php';
-$conf['cache_default_class'] = 'CacheGraceful';
-
Using Cache Backport:
$conf['cache_backends'] = array(
'sites/all/modules/cache_graceful/cache_graceful.inc',
diff --git a/cache_graceful.install b/cache_graceful.install
new file mode 100644
index 0000000..3ec54f4
--- /dev/null
+++ b/cache_graceful.install
@@ -0,0 +1,18 @@
+<?php
+/**
+ * @file
+ */
+
+/**
+ * Implements hook_uninstall().
+ */
+function cache_graceful_uninstall() {
+ variable_del('cache_graceful_wait_for_cache');
+ variable_del('cache_graceful_wait_for_cache_delay');
+ variable_del('cache_graceful_lock_timeout');
+ variable_del('cache_graceful_expire');
+ variable_del('cache_graceful_prefetch');
+ variable_del('cache_graceful_stale');
+ variable_del('cache_graceful_queue');
+}
+