public static function getCache()
 {
     if (self::$instance == null) {
         $cache = 'default';
         if (defined('OSC_CACHE')) {
             $cache = OSC_CACHE;
         }
         $cache_class = 'Object_Cache_' . $cache;
         $file = dirname(__FILE__) . '/caches/' . $cache_class . '.php';
         if (strpos($file, '../') === false && strpos($file, '..\\') === false && file_exists($file)) {
             require_once $file;
             if (class_exists($cache_class)) {
                 // all correct ?
                 if (call_user_func(array($cache_class, 'is_supported'))) {
                     self::$instance = new $cache_class();
                 } else {
                     $file = dirname(__FILE__) . '/caches/Object_Cache_default.php';
                     require_once $file;
                     self::$instance = new Object_Cache_default();
                     error_log('Cache ' . $cache . ' NOT SUPPORTED - loaded Object_Cache_default cache');
                 }
                 return self::$instance;
             }
         }
         throw new Exception('Unknown cache');
     } else {
         return self::$instance;
     }
 }
Example #2
0
        <a href="#" class="btn ico ico-32 ico-help float-right"></a>
    </h1>
    <?php 
}
function customPageTitle($string)
{
    return sprintf(__('Advanced Settings &raquo; %s'), $string);
}
osc_add_filter('admin_title', 'customPageTitle');
osc_current_admin_theme_path('parts/header.php');
?>
<div id="general-setting">
    <!-- settings form -->
    <div id="general-settings">
        <?php 
$cache_type = Object_Cache_Factory::newInstance()->_get_cache();
if ($cache_type != 'default') {
    ?>
        <!--    Cache flush    -->
        <h2 class="render-title"><?php 
    _e('Flush cache');
    ?>
</h2>
        <form id="cache_flush" name="cache_flush" action="<?php 
    echo osc_admin_base_url(true);
    ?>
" method="post">
            <input type="hidden" name="page" value="settings" />
            <input type="hidden" name="action" value="advanced_cache_flush" />
            <fieldset>
                <div class="form-horizontal">
Example #3
0
function osc_cache_set($key, $data, $expire = 0)
{
    $key .= osc_current_user_locale();
    return Object_Cache_Factory::newInstance()->set($key, $data, $expire);
}