diff sites/all/modules/ctools/plugins/cache/simple.inc @ 0:ff03f76ab3fe

initial version
author danieleb <danielebarchiesi@me.com>
date Wed, 21 Aug 2013 18:51:11 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sites/all/modules/ctools/plugins/cache/simple.inc	Wed Aug 21 18:51:11 2013 +0100
@@ -0,0 +1,51 @@
+<?php
+
+/**
+ * @file
+ * A simple cache indirection mechanism that just uses the basic object cache.
+ */
+
+$plugin = array(
+  // cache plugins are the rare plugin types that have no real UI but
+  // we're providing a title just in case.
+  'title' => t('Simple'),
+  'cache get' => 'ctools_cache_simple_cache_get',
+  'cache set' => 'ctools_cache_simple_cache_set',
+  'cache clear' => 'ctools_cache_simple_cache_clear',
+);
+
+function ctools_cache_simple_cache_get($data, $key) {
+  ctools_include('object-cache');
+
+  // Ensure that if there is somehow no data, we at least don't stomp on other
+  // people's caches.
+  if (empty($data)) {
+    $data = 'simple_cache_plugin';
+  }
+
+  return ctools_object_cache_get($data, $key);
+}
+
+function ctools_cache_simple_cache_set($data, $key, $object) {
+  ctools_include('object-cache');
+
+  // Ensure that if there is somehow no data, we at least don't stomp on other
+  // people's caches.
+  if (empty($data)) {
+    $data = 'simple_cache_plugin';
+  }
+
+  return ctools_object_cache_set($data, $key, $object);
+}
+
+function ctools_cache_simple_cache_clear($data, $key) {
+  ctools_include('object-cache');
+
+  // Ensure that if there is somehow no data, we at least don't stomp on other
+  // people's caches.
+  if (empty($data)) {
+    $data = 'simple_cache_plugin';
+  }
+
+  return ctools_object_cache_clear($data, $key);
+}