Xataface  2.0alpha2
Xataface Application Framework
 All Data Structures Namespaces Files Functions Variables Groups Pages
Cache.php
Go to the documentation of this file.
1 <?php
2 /*-------------------------------------------------------------------------------
3  * Xataface Web Application Framework
4  * Copyright (C) 2005-2008 Web Lite Solutions Corp (shannah@sfu.ca)
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *-------------------------------------------------------------------------------
20  */
25  var $prefix;
26 
30  var $cachedir;
31 
36  var $monitored = array();
37 
38  function Dataface_Cache($cachedir=null, $prefix=null){
39  if ( $cachedir === null ) $cachedir = '/tmp';
40  $this->cachedir = $cachedir;
41  if ( $prefix === null ) $prefix = DATAFACE_SITE_PATH;
42  $this->prefix = $prefix;
43 
44 
45  }
46 
47  function apc_get($key){
48  return apc_fetch($this->prefix.$key);
49  }
50 
51  function apc_set($key, &$value){
52  return apc_store($this->prefix.$key, $value);
53  }
54 
55  function get($key){
56  return $this->apc_get($key);
57  }
58 
59  function set($key, &$value){
60  return $this->apc_set($key, $value);
61  }
62 
63  public static function &getInstance(){
64  static $instance = null;
65  if ( $instance === null ){
66  $instance = new Dataface_Cache();
67  }
68  return $instance;
69  }
70 
71 }
72