当前位置: 首页>>代码示例>>PHP>>正文


PHP phpFastCache::set方法代码示例

本文整理汇总了PHP中phpFastCache::set方法的典型用法代码示例。如果您正苦于以下问题:PHP phpFastCache::set方法的具体用法?PHP phpFastCache::set怎么用?PHP phpFastCache::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在phpFastCache的用法示例。


在下文中一共展示了phpFastCache::set方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: clean

 /**
  * Clean up all cache
  */
 public static function clean()
 {
     self::$LASTCLEAN = time();
     if (SessionAccountHandler::getId() === null) {
         self::$cache->clean();
     } else {
         self::$cache->set('LASTCLEAN' . SessionAccountHandler::getId(), self::$LASTCLEAN);
     }
 }
开发者ID:guancio,项目名称:Runalyze,代码行数:12,代码来源:class.Cache.php

示例2: SSLForwardJS

 public function SSLForwardJS()
 {
     $ip = $this->getRealIP();
     if (!class_exists("phpFastCache")) {
         die("Please required phpFastCache Class");
     }
     // you should change this to cURL()
     $data = phpFastCache::get("codehelper_ip_ssl" . md5($ip));
     // caching 1 week
     if ($data == null) {
         $url = "http://api.codehelper.io/ips/?callback=codehelper_ip_callback&ip=" . $ip;
         $data = file_get_contents($url);
         phpFastCache::set("codehelper_ip_ssl" . md5($ip), $data, 3600 * 24 * 7);
     }
     return $data;
 }
开发者ID:Inteleck,项目名称:hwc,代码行数:16,代码来源:ip.codehelper.io.php

示例3: SSLForwardJS

 public function SSLForwardJS()
 {
     $ip = $this->getRealIP();
     if (!class_exists("phpFastCache")) {
         die("<div style='border: 2px solid #09f; font-size: .8em; font-family: Arial;background: #FCF0F0;border: 2px solid #F07272;padding: 10px;'>Please enable plugin <b>Cache</b> to run plugin <b>Statistic</b>!</div>");
     }
     // you should change this to cURL()
     $data = phpFastCache::get("codehelper_ip_ssl" . md5($ip));
     // caching 1 week
     if ($data == null) {
         $ctx = stream_context_create(array('http' => array('timeout' => 0.5)));
         $url = "http://api.codehelper.io/ips/?callback=codehelper_ip_callback&ip=" . $ip;
         $json = file_get_html($url);
         phpFastCache::set("codehelper_ip_ssl" . md5($ip), $data, 3600 * 24 * 7);
     }
     return $data;
 }
开发者ID:mul14,项目名称:FiyoCMS,代码行数:17,代码来源:ip.codehelper.io.php

示例4: getLocation

 public function getLocation($ip = "")
 {
     if ($ip == "") {
         $ip = $this->getRealIP();
     }
     if (!class_exists("phpFastCache")) {
         die("Please required phpFastCache Class");
     }
     // you should change this to cURL()
     $data = phpFastCache::get("codehelper_ip_" . md5($ip));
     // caching 1 week
     if ($data == null) {
         $url = "http://api.codehelper.io/ips/?php&ip=" . $ip;
         $json = file_get_contents($url);
         $data = json_decode($json, true);
         phpFastCache::set("codehelper_ip_" . md5($ip), $data, 3600 * 24 * 7);
     }
     return $data;
 }
开发者ID:cityware,项目名称:city-utility,代码行数:19,代码来源:IpAddress.php

示例5: updatecaching

function updatecaching()
{
    global $ts;
    $conn = 1;
    $errorCode = 0;
    $memcacheAuth = 0;
    include_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "cometchat_cache.php";
    if ($_POST['MC_NAME'] == 'memcachier') {
        $memcacheAuth = 1;
        $conn = 0;
        $memcache = new MemcacheSASL();
        $memcache->addServer($_POST['MC_SERVER'], $_POST['MC_PORT']);
        if ($memcachierAuth = $memcache->setSaslAuthData($_POST['MC_USERNAME'], $_POST['MC_PASSWORD'])) {
            $memcache->set('auth', 'ok');
            if (!($conn = $memcache->get('auth'))) {
                $errorCode = 3;
            }
            $memcache->delete('auth');
        } else {
            $errorCode = 3;
        }
    } elseif ($_POST['MC_NAME'] != '') {
        $conn = 0;
        $memcacheAuth = 1;
        phpFastCache::setup("storage", $_POST['MC_NAME']);
        $memcache = new phpFastCache();
        $driverPresent = isset($memcache->driver->option['availability']) ? 0 : 1;
        if ($driverPresent) {
            if ($_POST['MC_NAME'] == 'memcache') {
                $server = array(array($_POST['MC_SERVER'], $_POST['MC_PORT'], 1));
                $memcache->option('server', $server);
            }
            $memcache->set('auth', 'ok', 30);
            if (!($conn = $memcache->get('auth'))) {
                $errorCode = 1;
            }
            $memcache->delete('auth');
        }
    }
    if ($conn && !$errorCode) {
        $data = 'define(\'MEMCACHE\',\'' . $memcacheAuth . '\');' . "\r\n";
        $data .= 'define(\'MC_SERVER\',\'' . $_POST['MC_SERVER'] . '\');' . "\t// Set name of your memcache  server\r\n";
        $data .= 'define(\'MC_PORT\',\'' . $_POST['MC_PORT'] . '\');' . "\t\t\t// Set port of your memcache  server\r\n";
        $data .= 'define(\'MC_USERNAME\',\'' . $_POST['MC_USERNAME'] . '\');' . "\t\t\t\t\t\t\t// Set username of memcachier  server\r\n";
        $data .= 'define(\'MC_PASSWORD\',\'' . $_POST['MC_PASSWORD'] . '\');' . "\t\t\t// Set password your memcachier  server\r\n";
        $data .= 'define(\'MC_NAME\',\'' . $_POST['MC_NAME'] . '\');' . "\t\t\t// Set name of caching method if 0 : '', 1 : memcache, 2 : files, 3 : memcachier, 4 : apc, 5 : wincache, 6 : sqlite & 7 : memcached";
        configeditor('MEMCACHE', $data, 0);
        $_SESSION['cometchat']['error'] = 'Caching details updated successfully.';
    } else {
        if ($_POST['MC_NAME'] == 'memcachier') {
            $_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your Memchachier server details';
        } elseif ($_POST['MC_NAME'] == 'files') {
            $_SESSION['cometchat']['error'] = 'Please check file permission of your cache directory. Please try 755/777/644';
        } elseif ($_POST['MC_NAME'] == 'apc') {
            $_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your APC configuration.';
        } elseif ($_POST['MC_NAME'] == 'wincache') {
            $_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your Wincache configuration.';
        } elseif ($_POST['MC_NAME'] == 'sqlite') {
            $_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your SQLite configuration.';
        } elseif ($_POST['MC_NAME'] == 'memcached') {
            $_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your Memcached configuration.';
        } else {
            $_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your Memcache server configuration.';
        }
    }
    header("Location:?module=settings&action=caching&ts={$ts}");
}
开发者ID:networksoft,项目名称:goldenquick.pekcellgold.com,代码行数:67,代码来源:settings.m.php

示例6: file_get_contents

<?php

include "php_fast_cache.php";
phpFastCache::$storage = "auto";
// ready ?
// check in case first
$content = phpFastCache::get("keyword1");
if ($content == null) {
    // for testing
    echo "This is not caching, page is render with lot queires and slow speed <br>";
    // do what you want, like get content from cURL | API | mySQL Query and return result to $content
    $content = file_get_contents("http://www.phpfastcache.com/testing.php");
    // rewrite cache for other request in 5 seconds
    phpFastCache::set("keyword1", $content, 5);
} else {
    // use cache
    // node
    echo "THIS TIME USE CACHE, FAST! <br>";
}
echo "TRY F5 to refesh the page to see new SPEED with Cache!<br>";
echo $content;
开发者ID:sankam-nikolya,项目名称:lptt,代码行数:21,代码来源:example.php

示例7: array

phpFastCache::debug(phpFastCache::systemInfo());
echo "<b>Data will be testing - Included NULL and Emptry String</b>";
phpFastCache::debug($data);
$c = array("red", "blue", "green", "orange", "black", "red", "blue", "green", "orange", "black");
$xx = 0;
foreach ($caching as $st) {
    $dem = 0;
    $color = $c[$xx];
    $xx++;
    phpFastCache::$storage = $st;
    echo "<font color={$color} >\n    ------------------------------------------------- <br>\n    Caching = {$st} <br>";
    if (isset(phpFastCache::$sys['drivers'][$st]) && phpFastCache::$sys['drivers'][$st] == true || $st == "auto") {
        foreach ($data as $string) {
            $dem++;
            echo "SET {$dem} --> ";
            phpFastCache::set("A" . $dem, $string);
            echo "GET {$dem} = ";
            $x = phpFastCache::get("A" . $dem);
            if (is_array($x)) {
                print_r($x);
            } else {
                echo $x;
                if (is_numeric($x)) {
                    phpFastCache::increment("A" . $dem);
                    phpFastCache::increment("A" . $dem);
                    phpFastCache::increment("A" . $dem);
                    $x = phpFastCache::get("A" . $dem);
                    echo " Increase to " . $x;
                    phpFastCache::decrement("A" . $dem);
                    phpFastCache::decrement("A" . $dem);
                    phpFastCache::decrement("A" . $dem);
开发者ID:sankam-nikolya,项目名称:lptt,代码行数:31,代码来源:testing.php

示例8: updatecaching

function updatecaching()
{
    global $ts;
    $conn = 1;
    $errorCode = 0;
    $memcacheAuth = 0;
    include_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "cometchat_cache.php";
    if ($_POST['MC_NAME'] == 'memcachier') {
        $memcacheAuth = 1;
        $conn = 0;
        $memcache = new MemcacheSASL();
        $memcache->addServer($_POST['MC_SERVER'], $_POST['MC_PORT']);
        if ($memcachierAuth = $memcache->setSaslAuthData($_POST['MC_USERNAME'], $_POST['MC_PASSWORD'])) {
            $memcache->set('auth', 'ok');
            if (!($conn = $memcache->get('auth'))) {
                $errorCode = 3;
            }
            $memcache->delete('auth');
        } else {
            $errorCode = 3;
        }
    } elseif ($_POST['MC_NAME'] != '') {
        $conn = 0;
        $memcacheAuth = 1;
        phpFastCache::setup("storage", $_POST['MC_NAME']);
        $memcache = new phpFastCache();
        $driverPresent = isset($memcache->driver->option['availability']) ? 0 : 1;
        if ($driverPresent) {
            if ($_POST['MC_NAME'] == 'memcache' && class_exists("Memcache") || $_POST['MC_NAME'] == 'memcached' && class_exists("Memcached")) {
                if ($_POST['MC_NAME'] == 'memcache') {
                    $server = array(array($_POST['MC_SERVER'], $_POST['MC_PORT'], 1));
                    $memcache->option('server', $server);
                }
                if ($_POST['MC_NAME'] == 'memcached') {
                    $server = array(array($_POST['MC_SERVER'], $_POST['MC_PORT'], 1));
                    $memcache->option('server', $server);
                }
                $memcache->set('auth', 'ok', 30);
                if (!($conn = $memcache->get('auth'))) {
                    $errorCode = 1;
                }
                $memcache->delete('auth');
            }
        }
    }
    if (!$errorCode) {
        configeditor($_POST);
        $_SESSION['cometchat']['error'] = 'Caching details updated successfully.';
    } else {
        if ($_POST['MC_NAME'] == 'memcachier') {
            $_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your Memchachier server details';
        } elseif ($_POST['MC_NAME'] == 'files') {
            $_SESSION['cometchat']['error'] = 'Please check file permission of your cache directory. Please try 755/777/644';
        } elseif ($_POST['MC_NAME'] == 'apc') {
            $_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your APC configuration.';
        } elseif ($_POST['MC_NAME'] == 'wincache') {
            $_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your Wincache configuration.';
        } elseif ($_POST['MC_NAME'] == 'sqlite') {
            $_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your SQLite configuration.';
        } elseif ($_POST['MC_NAME'] == 'memcached') {
            $_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your Memcached configuration.';
        } else {
            $_SESSION['cometchat']['error'] = 'Failed to update caching details. Please check your Memcache server configuration.';
        }
    }
    header("Location:?module=settings&action=caching&ts={$ts}");
}
开发者ID:albertoneto,项目名称:localhost,代码行数:67,代码来源:settings.m.php

示例9: date

    if (!empty($nonListed)) {
        $content .= "<p>The following ridings are not listed because they don't have enough votes counted yet: {$nonListed}</p>";
    }
    $content .= '<hr /><p><font size="-1">Results as of ' . date($dateFormat) . '</font></p>';
    phpFastCache::set("main", $content, 30);
    $content .= '<p><font size="-1">Non-cached results printed on ' . date($dateFormat) . '</font></p>';
    #$content .= '<pre>';
    #$content .= 'Values for entire jurisdiction: ';
    #$content .= var_export($entireJurisdiction, TRUE);
    #$content .= '</pre>';
    echo $content;
    if (!empty($entireJurisdiction['totalValidVotes']) && $entireJurisdiction['totalValidVotes'] > 0) {
        $number = $entireJurisdiction['wastedVotes'];
        phpFastCache::set("entireJurisdictionResult", $number, 60 * 60 * 24 * 365);
    } else {
        phpFastCache::set("entireJurisdictionResult", -1, 1);
    }
    webCommentPrint("List of parties are:\n");
    sort($listOfParties);
    foreach ($listOfParties as $partyName) {
        webCommentPrint("{$partyName}\n");
    }
    ### End of else for non-cached, fresh results
}
function webCommentPrint($comment)
{
    $comment = rtrim($comment);
    echo "<!-- {$comment} -->\n";
}
?>
开发者ID:cyclingzealot,项目名称:nb2014,代码行数:30,代码来源:index.php


注:本文中的phpFastCache::set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。