Revision: 10312
http://sourceforge.net/p/xoops/svn/10312
Author: trabis
Date: 2012-12-03 00:04:03 +0000 (Mon, 03 Dec 2012)
Log Message:
-----------
Uploading a cache usage example.
Added Paths:
-----------
XoopsCore/branches/2.6.x/2.6.0/htdocs/examples/cache.php
Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/examples/cache.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0/htdocs/examples/cache.php (rev 0)
+++ XoopsCore/branches/2.6.x/2.6.0/htdocs/examples/cache.php 2012-12-03 00:04:03 UTC (rev 10312)
@@ -0,0 +1,55 @@
+<?php
+/*
+ You may not change or alter any portion of this comment or credits
+ of supporting developers from this source code or any supporting source code
+ which is considered copyrighted (c) material of the original comment or credit authors.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/**
+ * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/
+ * @license http://www.fsf.org/copyleft/gpl.html GNU public license
+ * @author trabis <lus...@gm...>
+ * @version $Id$
+ */
+
+include dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'mainfile.php';
+
+if (isset($_GET['delete'])) {
+ Xoops_Cache::delete('mykey');
+ Xoops_Cache::delete('mykey2', 'myfilesystem');
+ Xoops_Cache::delete('mykey3', 'mymemcache');
+}
+
+$content = time();
+
+//using 'default' cache file system
+if (!$ret = Xoops_Cache::read('mykey')) {
+ Xoops_Cache::write('mykey', $content);
+ $ret = $content;
+}
+echo $ret . '<br />';
+
+//setting new cache file system
+Xoops_Cache::config('myfilesystem', array('engine' => 'file', 'duration' => 10));
+if (!$ret = Xoops_Cache::read('mykey2', 'myfilesystem')) {
+ $ret = Xoops_Cache::write('mykey2', $content, 'myfilesystem');
+ $ret = $content;
+}
+echo $ret . '<br />';
+
+//setting new cache memcache system
+Xoops_Cache::config('mymemcache', array('engine' => 'memcache', 'duration' => 5));
+if (!$ret = Xoops_Cache::read('mykey3', 'mymemcache')) {
+ if(Xoops_Cache::write('mykey3', $content, 'mymemcache')) {
+ $ret = $content;
+ } else |