I'm using the ctools object cache in an ajax callback to store data so it is available later in a Solr hook. The data is stored fine in the table when I call ctools_object_cache_set(), but when I retrieve the data with ctools_object_cache_get(), I just get an empty object. In stepping through the ctools_object_cache_set() code, it chokes when it tries to unserialize the data. Here is the code I'm using to serialize it:

  foreach ($form_state['values'] as $id => $tids) {
    if (substr($id, 0, 6) == 'vocab_') {
      $vid = substr($id, 6);
      $filters = new stdClass();
      foreach ($tids as $tid) {
        if ($tid) {
          $filters->{$tid} = $tid;
        }
      }
      // Cache the object in ctools cache so it's available later.
      ctools_include('object-cache');
      ctools_object_cache_set('solr_filters', $id, $filters);
    }
  }

Is there something I'm doing in creating my object that's causing the problem? This is my first time using ctools object caching, so there's always that possibility.

Thanks.

Comments

wonder95’s picture

Status: Active » Closed (fixed)

The problem was that I was using an integer as a property in my $filters object. Once I changed it to

$filters->tids[$tid] = $tid;

the retrieving worked fine.