You are here

public static function QPCache::get in QueryPath 7.3

Same name and namespace in other branches
  1. 6 qpcache/qpcache.module \QPCache::get()
  2. 7.2 qpcache/qpcache.module \QPCache::get()

Return the value of the given key, if it exists in the database.

If no value is found, this will return NULL.

2 calls to QPCache::get()
qpcache_get in qpcache/qpcache.module
Retrieve an object from the cache.
qpcache_qp in qpcache/qpcache.module
Factory for creating a QueryPath object.

File

qpcache/qpcache.module, line 221
The main file for qpcache.

Class

QPCache
This is a special-purpose XML cache.

Code

public static function get($key) {
  list($crc, $hash) = self::genMultiKey($key);
  $now = time();

  // if (is_array($key)) {
  //       drupal_set_message('Retrieval key is array.', 'status');
  //     }
  $sql = 'SELECT clearkey, expire, body FROM {qpcache_xmlcache} WHERE crckey=\':crc\' AND hashkey=\':hash\' AND (expire = 0 OR expire > \':now\')';
  $result = db_query($sql, array(
    ':crc' => $crc,
    ':hash' => $hash,
    ':now' => $now,
  ));
  if (empty($result)) {
    return;
  }
  foreach ($result as $object) {
    $object->xml = $object->body;
    return $object;
  }
}