XOOPS  2.6.0
Legacy.php
Go to the documentation of this file.
1 <?php
11 namespace Xoops\Core\Cache;
12 
23 class Legacy
24 {
31  private static function deprecated($message = 'Obsolete cache call.')
32  {
33  //\Xoops::getInstance()->deprecated($message);
34  $stack = debug_backtrace();
35  $frameSelf = $stack[1];
36  $frame = isset($stack[2]) ? $stack[2] : false;
37  $append = ' ' . get_called_class() . '::' . $frameSelf['function'] . '() called from ';
38  if ($frame !== false) {
39  $append .= $frame['function'] . '() in ';
40  }
41  $append .= $frameSelf['file'] . ' line '. $frameSelf['line'];
42  \Xoops::getInstance()->deprecated($message . $append);
43  }
44 
50  private static function getCache()
51  {
52  return \Xoops::getInstance()->cache();
53  }
54 
60  public static function gc()
61  {
62  self::deprecated();
63  $cache = self::getCache();
64  return $cache->garbageCollect();
65  }
66 
76  public static function write($key, $value, $duration = 0)
77  {
78  self::deprecated();
79  $ttl = intval($duration);
80  $ttl = $ttl > 0 ? $ttl : null;
81  $cache = self::getCache();
82  return $cache->write($key, $value, $ttl);
83 
84  //$key = substr(md5(\XoopsBaseConfig::get('url')), 0, 8) . '_' . $key;
85  }
86 
94  public static function read($key)
95  {
96  self::deprecated();
97  $cache = self::getCache();
98  return $cache->read($key);
99  }
100 
108  public static function delete($key)
109  {
110  self::deprecated();
111  $cache = self::getCache();
112  return $cache->delete($key);
113  }
114 
120  public static function clear()
121  {
122  self::deprecated();
123  $cache = self::getCache();
124  return $cache->clear();
125  }
126 
135  public function __call($name, $args)
136  {
137  self::deprecated(sprintf('XoopsCache->%s() is no longer used', $name));
138  return false;
139  }
140 
149  public static function __callStatic($name, $args)
150  {
151  self::deprecated(sprintf('XoopsCache::%s() is no longer used', $name));
152  return false;
153  }
154 }
static getInstance()
Definition: Xoops.php:160
static read($key)
Definition: Legacy.php:94
static __callStatic($name, $args)
Definition: Legacy.php:149
__call($name, $args)
Definition: Legacy.php:135
static write($key, $value, $duration=0)
Definition: Legacy.php:76
static deprecated($message= 'Obsolete cache call.')
Definition: Legacy.php:31