function ctools_object_cache_get

nittany7 object-cache.inc ctools_object_cache_get($obj, $name, $skip_cache = FALSE, $sid = NULL)
cis7 object-cache.inc ctools_object_cache_get($obj, $name, $skip_cache = FALSE, $sid = NULL)
mooc7 object-cache.inc ctools_object_cache_get($obj, $name, $skip_cache = FALSE, $sid = NULL)

Get an object from the non-volatile ctools cache.

This function caches in memory as well, so that multiple calls to this will not result in multiple database reads.

Parameters

$obj: A 128 character or less string to define what kind of object is being stored; primarily this is used to prevent collisions.

$name: The name of the object being stored.

$skip_cache: Skip the memory cache, meaning this must be read from the db again.

$sid: The session id, allowing someone to use Session API or their own solution; defaults to session_id().

Return value

The data that was cached.

Deprecated

$skip_cache is deprecated in favor of drupal_static*

9 calls to ctools_object_cache_get()
CtoolsObjectCache::testObjectStorage in modules/contrib/ctools/tests/object_cache.test
ctools_ajax_sample_cache_get in modules/contrib/ctools/ctools_ajax_sample/ctools_ajax_sample.module
Get the current object from the cache, or default.
ctools_cache_simple_cache_get in modules/contrib/ctools/plugins/cache/simple.inc
ctools_export_ui::edit_cache_get in modules/contrib/ctools/plugins/export_ui/ctools_export_ui.class.php
Retrieve the item currently being edited from the object cache.
ctools_stylizer_get_settings_cache in modules/contrib/ctools/includes/stylizer.inc
Get the cached changes to a given task handler.

... See full list

2 string references to 'ctools_object_cache_get'
ctools_object_cache_clear in modules/contrib/ctools/includes/object-cache.inc
Remove an object from the non-volatile ctools cache
ctools_object_cache_clear_all in modules/contrib/ctools/includes/object-cache.inc
Remove an object from the non-volatile ctools cache for all session IDs.

File

modules/contrib/ctools/includes/object-cache.inc, line 33
The non-volatile object cache is used to store an object while it is being edited, so that we don't have to save until we're completely done. The cache should be 'cleaned' on a regular basis, meaning to remove old objects from theā€¦

Code

function ctools_object_cache_get($obj, $name, $skip_cache = FALSE, $sid = NULL) {
  $cache = &drupal_static(__FUNCTION__, array());
  $key = "$obj:$name";
  if ($skip_cache) {
    unset($cache[$key]);
  }

  if (!$sid) {
    $sid = session_id();
  }

  if (!array_key_exists($key, $cache)) {
    $data = db_query('SELECT * FROM {ctools_object_cache} WHERE sid = :session_id AND obj = :object AND name = :name', array(':session_id' => $sid, ':object' => $obj, ':name' => $name))->fetchObject();
    if ($data) {
      $cache[$key] = unserialize($data->data);
    }
  }
  return isset($cache[$key]) ? $cache[$key] : NULL;
}