simple.inc 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * @file
  4. * A simple cache indirection mechanism that just uses the basic object cache.
  5. */
  6. $plugin = array(
  7. // cache plugins are the rare plugin types that have no real UI but
  8. // we're providing a title just in case.
  9. 'title' => t('Simple'),
  10. 'cache get' => 'ctools_cache_simple_cache_get',
  11. 'cache set' => 'ctools_cache_simple_cache_set',
  12. 'cache clear' => 'ctools_cache_simple_cache_clear',
  13. );
  14. function ctools_cache_simple_cache_get($data, $key) {
  15. ctools_include('object-cache');
  16. // Ensure that if there is somehow no data, we at least don't stomp on other
  17. // people's caches.
  18. if (empty($data)) {
  19. $data = 'simple_cache_plugin';
  20. }
  21. return ctools_object_cache_get($data, $key);
  22. }
  23. function ctools_cache_simple_cache_set($data, $key, $object) {
  24. ctools_include('object-cache');
  25. // Ensure that if there is somehow no data, we at least don't stomp on other
  26. // people's caches.
  27. if (empty($data)) {
  28. $data = 'simple_cache_plugin';
  29. }
  30. return ctools_object_cache_set($data, $key, $object);
  31. }
  32. function ctools_cache_simple_cache_clear($data, $key) {
  33. ctools_include('object-cache');
  34. // Ensure that if there is somehow no data, we at least don't stomp on other
  35. // people's caches.
  36. if (empty($data)) {
  37. $data = 'simple_cache_plugin';
  38. }
  39. return ctools_object_cache_clear($data, $key);
  40. }