/[drupal]/contributions/modules/simplelist/SimpleListCachingEngine.php
ViewVC logotype

Contents of /contributions/modules/simplelist/SimpleListCachingEngine.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Mon May 19 03:44:37 2008 UTC (18 months, 1 week ago) by jcfiala
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +3 -3 lines
File MIME type: text/x-php
#259764 by jcfiala: Fixed badly broken caching engine, and added tests to verify the fix.
1 <?php
2 // $Id$
3
4 require_once(drupal_get_path('module', 'simplelist') .'/SimpleListInterfaceCachingEngine.php');
5 /**
6 * The caching engine uses the standard drupal cache functions to store loaded nodes for a short time. This keeps down the
7 * possibly complicated load-times that happen when a node is loaded by passing it around through nodeapi.
8 *
9 * We save the cached data in cache_block, because it will be invalidated when a node is updated or inserted.
10 */
11 class SimpleListCachingEngine implements SimpleListInterfaceCachingEngine {
12 public function fetch_node($nid) {
13 $cache_data = cache_get($this->get_node_cache_id($nid), 'cache_block');
14 //drupal_set_message('cache:'. dprint_r($cache_data, true));
15 if ($cache_data) {
16 return $cache_data->data;
17 }
18 else {
19 $node = node_load($nid);
20 cache_set($this->get_node_cache_id($nid), $node, 'cache_block', CACHE_TEMPORARY);
21 return $node;
22 }
23 }
24
25 public function get_node_cache_id($nid) {
26 global $user;
27 return 'node_'. implode(',', array_keys($user->roles)) .'_'. $nid;
28 }
29 }
30 ?>

  ViewVC Help
Powered by ViewVC 1.1.2