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


PHP output_cache_put函数代码示例

本文整理汇总了PHP中output_cache_put函数的典型用法代码示例。如果您正苦于以下问题:PHP output_cache_put函数的具体用法?PHP output_cache_put怎么用?PHP output_cache_put使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: set

 function set($key, $value)
 {
     parent::set($key, $value);
     // caching is turned off
     if (!$GLOBALS['external_cache_enabled']) {
         return;
     }
     $external_key = $this->_realKey($key);
     if (EXTERNAL_CACHE_DEBUG) {
         SugarCache::log("Step 3: Converting key ({$key}) to external key ({$external_key})");
     }
     output_cache_put($external_key, serialize($value));
     if (EXTERNAL_CACHE_DEBUG) {
         SugarCache::log("Step 4: Added key to Zend cache {$external_key} with value ({$value}) to be stored for " . EXTERNAL_CACHE_INTERVAL_SECONDS . " seconds");
     }
 }
开发者ID:aldridged,项目名称:gtg-sugar,代码行数:16,代码来源:SugarCache_Zend.php

示例2: cache_put_data

function cache_put_data($key, $value, $ttl = 120)
{
    global $boardurl, $sourcedir, $modSettings, $memcached;
    global $cache_hits, $cache_count, $db_show_debug;
    if (empty($modSettings['cache_enable']) && !empty($modSettings)) {
        return;
    }
    $cache_count = isset($cache_count) ? $cache_count + 1 : 1;
    if (isset($db_show_debug) && $db_show_debug === true) {
        $cache_hits[$cache_count] = array('k' => $key, 'd' => 'put', 's' => $value === null ? 0 : strlen(serialize($value)));
        $st = microtime();
    }
    $key = md5($boardurl . filemtime($sourcedir . '/Load.php')) . '-SMF-' . $key;
    $value = $value === null ? null : serialize($value);
    // The simple yet efficient memcached.
    if (function_exists('memcache_set') && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '') {
        // Not connected yet?
        if (empty($memcached)) {
            get_memcached_server();
        }
        if (!$memcached) {
            return;
        }
        memcache_set($memcached, $key, $value, 0, $ttl);
    } elseif (function_exists('eaccelerator_put')) {
        if (mt_rand(0, 10) == 1) {
            eaccelerator_gc();
        }
        if ($value === null) {
            @eaccelerator_rm($key);
        } else {
            eaccelerator_put($key, $value, $ttl);
        }
    } elseif (function_exists('mmcache_put')) {
        if (mt_rand(0, 10) == 1) {
            mmcache_gc();
        }
        if ($value === null) {
            @mmcache_rm($key);
        } else {
            mmcache_put($key, $value, $ttl);
        }
    } elseif (function_exists('apc_store')) {
        // An extended key is needed to counteract a bug in APC.
        if ($value === null) {
            apc_delete($key . 'smf');
        } else {
            apc_store($key . 'smf', $value, $ttl);
        }
    } elseif (function_exists('output_cache_put')) {
        output_cache_put($key, $value);
    }
    if (isset($db_show_debug) && $db_show_debug === true) {
        $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
    }
}
开发者ID:alencarmo,项目名称:OCF,代码行数:56,代码来源:Load.php

示例3: save

 /**
  * Save some string datas into a cache record
  *
  * Note : $data is always "string" (serialization is done by the
  * core not by the backend)
  *
  * @param string $data data to cache
  * @param string $id cache id
  * @param array $tags array of strings, the cache record will be tagged by each string entry
  * @param int $specificLifetime if != false, set a specific lifetime for this cache record (null => infinite lifetime)
  * @return boolean true if no problem
  */
 public function save($data, $id, $tags = array(), $specificLifetime = false)
 {
     if (!($specificLifetime === false)) {
         $this->_log("Zend_Cache_Backend_ZendPlatform::save() : non false specifc lifetime is unsuported for this backend");
     }
     $lifetime = $this->_directives['lifetime'];
     $result1 = output_cache_put($id, array($data, time()));
     $result2 = count($tags) == 0;
     foreach ($tags as $tag) {
         $tagid = self::TAGS_PREFIX . $tag;
         $old_tags = output_cache_get($tagid, $lifetime);
         if ($old_tags === false) {
             $old_tags = array();
         }
         $old_tags[$id] = $id;
         $result2 = output_cache_put($tagid, $old_tags);
     }
     return $result1 && $result2;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:31,代码来源:ZendPlatform.php

示例4: smfapi_cachePutData

/**
 * Put data in the cache
 *
 * Adds data to whatever cache method we're using
 *
 * @param  string $key the cache data identifier
 * @param  mixed $value the value to be stored
 * @param  int $ttl how long are we going to cache this data (in seconds)
 * @return void
 * @since  0.1.0
 */
function smfapi_cachePutData($key, $value, $ttl = 120)
{
    global $boardurl, $sourcedir, $modSettings, $memcached;
    global $cache_hits, $cache_count, $db_show_debug, $cachedir;
    if (empty($modSettings['cache_enable']) && !empty($modSettings)) {
        return;
    }
    $cache_count = isset($cache_count) ? $cache_count + 1 : 1;
    if (isset($db_show_debug) && $db_show_debug === true) {
        $cache_hits[$cache_count] = array('k' => $key, 'd' => 'put', 's' => $value === null ? 0 : strlen(serialize($value)));
        $st = microtime();
    }
    $key = md5($boardurl . filemtime($sourcedir . '/Load.php')) . '-SMF-' . strtr($key, ':', '-');
    $value = $value === null ? null : serialize($value);
    // eAccelerator...
    if (function_exists('eaccelerator_put')) {
        if (mt_rand(0, 10) == 1) {
            eaccelerator_gc();
        }
        if ($value === null) {
            @eaccelerator_rm($key);
        } else {
            eaccelerator_put($key, $value, $ttl);
        }
    } elseif (function_exists('mmcache_put')) {
        if (mt_rand(0, 10) == 1) {
            mmcache_gc();
        }
        if ($value === null) {
            @mmcache_rm($key);
        } else {
            mmcache_put($key, $value, $ttl);
        }
    } elseif (function_exists('apc_store')) {
        // An extended key is needed to counteract a bug in APC.
        if ($value === null) {
            apc_delete($key . 'smf');
        } else {
            apc_store($key . 'smf', $value, $ttl);
        }
    } elseif (function_exists('output_cache_put')) {
        output_cache_put($key, $value);
    } elseif (function_exists('xcache_set') && ini_get('xcache.var_size') > 0) {
        if ($value === null) {
            xcache_unset($key);
        } else {
            xcache_set($key, $value, $ttl);
        }
    } else {
        if ($value === null) {
            @unlink($cachedir . '/data_' . $key . '.php');
        } else {
            $cache_data = '<' . '?' . 'php if (!defined(\'SMF\')) die; if (' . (time() + $ttl) . ' < time()) $expired = true; else{$expired = false; $value = \'' . addcslashes($value, '\\\'') . '\';}' . '?' . '>';
            $fh = @fopen($cachedir . '/data_' . $key . '.php', 'w');
            if ($fh) {
                // write the file.
                set_file_buffer($fh, 0);
                flock($fh, LOCK_EX);
                $cache_bytes = fwrite($fh, $cache_data);
                flock($fh, LOCK_UN);
                fclose($fh);
                // check that the cache write was successful; all the data should be written
                // if it fails due to low diskspace, remove the cache file
                if ($cache_bytes != strlen($cache_data)) {
                    @unlink($cachedir . '/data_' . $key . '.php');
                }
            }
        }
    }
    if (isset($db_show_debug) && $db_show_debug === true) {
        $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
    }
    return;
}
开发者ID:rxadmin,项目名称:ufoai,代码行数:85,代码来源:smf_2_api.php

示例5: putCache

 /**
  * Store a value in cache.
  * 
  * @param string $key
  * @param mixed $value
  * @param int $ttl = 120
  */
 public static function putCache($key, $value, $ttl = 120)
 {
     if (-1 == self::$API) {
         return;
     }
     self::$cache_count++;
     if (self::$want_debug) {
         self::$cache_hits[self::$cache_count] = array('k' => $key, 'd' => 'put', 's' => $value === null ? 0 : strlen(serialize($value)));
         $st = microtime();
     }
     $key = self::$basekey . strtr($key, ':', '-');
     $value = $value === null ? null : serialize($value);
     switch (self::$API) {
         case 5:
             $key = str_replace(' ', '_', $key);
             $instance = self::getMemcachedServer();
             $instance->set($key, $value, $ttl);
             break;
         case 4:
             if (empty(self::$memcached)) {
                 self::getMemcacheServer();
             }
             if (!self::$memcached) {
                 return;
             }
             memcache_set(self::$memcached, $key, $value, 0, $ttl);
             break;
         case 1:
             // An extended key is needed to counteract a bug in APC.
             if ($value === null) {
                 apc_delete($key . 'smf');
             } else {
                 apc_store($key . 'smf', $value, $ttl);
             }
             break;
         case 3:
             output_cache_put($key, $value);
             break;
         case 2:
             if ($value === null) {
                 xcache_unset($key);
             } else {
                 xcache_set($key, $value, $ttl);
             }
             break;
         case 0:
             if ($value === null) {
                 @unlink(self::$cachedir . '/data_' . $key . '.php');
             } else {
                 $cache_data = '<' . '?' . 'php if (!defined(\'SMF\')) die; if (' . (time() + $ttl) . ' < time()) $expired = true; else{$expired = false; $value = \'' . addcslashes($value, '\\\'') . '\';}' . '?' . '>';
                 $fh = @fopen(self::$cachedir . '/data_' . $key . '.php', 'w');
                 if ($fh) {
                     // Write the file.
                     set_file_buffer($fh, 0);
                     flock($fh, LOCK_EX);
                     $cache_bytes = fwrite($fh, $cache_data);
                     flock($fh, LOCK_UN);
                     fclose($fh);
                     // Check that the cache write was successful; all the data should be written
                     // If it fails due to low diskspace, remove the cache file
                     if ($cache_bytes != strlen($cache_data)) {
                         @unlink(self::$cachedir . '/data_' . $key . '.php');
                     }
                 }
             }
             break;
     }
     if (isset($db_show_debug) && $db_show_debug === true) {
         self::$cache_hits[self::$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
     }
 }
开发者ID:norv,项目名称:EosAlpha,代码行数:78,代码来源:CommonAPI.php

示例6: store

 /**
  * Save cache content into the ZendPlatform storage.
  * Data is already serialized.
  *
  * @param   string  $data    Data to store.
  * @return  void
  */
 public function store($data)
 {
     $this->clean();
     output_cache_put($this->getIdMd5(), [$data, time()]);
     return;
 }
开发者ID:Jir4,项目名称:Cache,代码行数:13,代码来源:ZendPlatform.php

示例7: cache_put_data

/**
 * Puts value in the cache under key for ttl seconds.
 *
 * - It may "miss" so shouldn't be depended on
 * - Uses the cache engine chosen in the ACP and saved in settings.php
 * - It supports:
 *     Turck MMCache: http://turck-mmcache.sourceforge.net/index_old.html#api
 *     Xcache: http://xcache.lighttpd.net/wiki/XcacheApi
 *     memcache: http://www.php.net/memcache
 *     APC: http://www.php.net/apc
 *     eAccelerator: http://bart.eaccelerator.net/doc/phpdoc/
 *     Zend: http://files.zend.com/help/Zend-Platform/output_cache_functions.htm
 *     Zend: http://files.zend.com/help/Zend-Platform/zend_cache_functions.htm
 *
 * @param string $key
 * @param string|int|mixed[]|null $value
 * @param int $ttl = 120
 */
function cache_put_data($key, $value, $ttl = 120)
{
    global $cache_memcached, $memcached, $cache_hits, $cache_count, $db_show_debug;
    global $cache_accelerator, $cache_enable;
    if (empty($cache_enable)) {
        return;
    }
    $cache_count = isset($cache_count) ? $cache_count + 1 : 1;
    if (isset($db_show_debug) && $db_show_debug === true) {
        $cache_hits[$cache_count] = array('k' => $key, 'd' => 'put', 's' => $value === null ? 0 : strlen(serialize($value)));
        $st = microtime(true);
    }
    $key = cache_get_key($key);
    $value = $value === null ? null : serialize($value);
    switch ($cache_accelerator) {
        case 'memcached':
            // The simple yet efficient memcached.
            if (function_exists('memcached_set') || function_exists('memcache_set') && !empty($cache_memcached)) {
                // Not connected yet?
                if (empty($memcached)) {
                    get_memcached_server();
                }
                if (!$memcached) {
                    return;
                }
                memcache_set($memcached, $key, $value, 0, $ttl);
            }
            break;
        case 'eaccelerator':
            // eAccelerator...
            if (function_exists('eaccelerator_put')) {
                if (mt_rand(0, 10) == 1) {
                    eaccelerator_gc();
                }
                if ($value === null) {
                    @eaccelerator_rm($key);
                } else {
                    eaccelerator_put($key, $value, $ttl);
                }
            }
            break;
        case 'mmcache':
            // Turck MMCache?
            if (function_exists('mmcache_put')) {
                if (mt_rand(0, 10) == 1) {
                    mmcache_gc();
                }
                if ($value === null) {
                    @mmcache_rm($key);
                } else {
                    mmcache_lock($key);
                    mmcache_put($key, $value, $ttl);
                    mmcache_unlock($key);
                }
            }
            break;
        case 'apc':
        case 'apcu':
            // Alternative PHP Cache, ahoy!
            if (function_exists('apc_store')) {
                // An extended key is needed to counteract a bug in APC.
                if ($value === null) {
                    apc_delete($key . 'elkarte');
                } else {
                    apc_store($key . 'elkarte', $value, $ttl);
                }
            }
            break;
        case 'zend':
            // Zend Platform/ZPS/etc.
            if (function_exists('zend_shm_cache_store')) {
                zend_shm_cache_store('ELK::' . $key, $value, $ttl);
            } elseif (function_exists('output_cache_put')) {
                output_cache_put($key, $value);
            }
            break;
        case 'xcache':
            if (function_exists('xcache_set') && ini_get('xcache.var_size') > 0) {
                if ($value === null) {
                    xcache_unset($key);
                } else {
                    xcache_set($key, $value, $ttl);
//.........这里部分代码省略.........
开发者ID:KeiroD,项目名称:Elkarte,代码行数:101,代码来源:Cache.subs.php

示例8: store

 /**
  * Write data to cache.
  *
  * @param string $id cache id
  *
  * @param string $data
  *
  * @return bool success
  */
 public function store($id, $data)
 {
     return output_cache_put($id, "{$_SERVER['REQUEST_TIME']}|{$data}");
 }
开发者ID:thodison,项目名称:minify,代码行数:13,代码来源:ZendPlatform.php

示例9: save

 /**
  * Save some string datas into a cache record
  *
  * Note : $data is always "string" (serialization is done by the
  * core not by the backend)
  *
  * @param string $data data to cache
  * @param string $id cache id
  * @param array $tags array of strings, the cache record will be tagged by each string entry
  * *                  This option is not supported in this backend
  * @return boolean true if no problem
  */
 public function save($data, $id, $tags = array())
 {
     $result = output_cache_put($id, array($data, time()));
     if (count($tags) > 0) {
         foreach ($tags as $tag) {
             $tagid = self::TAGS_PREFIX . $tag;
             $old_tags = output_cache_get($tagid, $this->_directives['lifeTime']);
             if ($old_tags === false) {
                 $old_tags = array();
             }
             $old_tags[$id] = $id;
             output_cache_put($tagid, $old_tags);
         }
     }
     return $result;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:28,代码来源:ZendPlatform.php

示例10: cache_put_data

function cache_put_data($key, $value, $ttl = 120)
{
    global $boardurl, $sourcedir, $modSettings, $memcached;
    global $cache_hits, $cache_count, $db_show_debug, $cachedir;
    if (empty($modSettings['cache_enable']) && !empty($modSettings)) {
        return;
    }
    $cache_count = isset($cache_count) ? $cache_count + 1 : 1;
    if (isset($db_show_debug) && $db_show_debug === true) {
        $cache_hits[$cache_count] = array('k' => $key, 'd' => 'put', 's' => $value === null ? 0 : strlen(serialize($value)));
        $st = microtime();
    }
    $key = md5($boardurl . filemtime($sourcedir . '/Load.php')) . '-SMF-' . strtr($key, ':', '-');
    $value = $value === null ? null : serialize($value);
    // The simple yet efficient memcached.
    if (function_exists('memcache_set') && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '') {
        // Not connected yet?
        if (empty($memcached)) {
            get_memcached_server();
        }
        if (!$memcached) {
            return;
        }
        memcache_set($memcached, $key, $value, 0, $ttl);
    } elseif (function_exists('eaccelerator_put')) {
        if (mt_rand(0, 10) == 1) {
            eaccelerator_gc();
        }
        if ($value === null) {
            @eaccelerator_rm($key);
        } else {
            eaccelerator_put($key, $value, $ttl);
        }
    } elseif (function_exists('mmcache_put')) {
        if (mt_rand(0, 10) == 1) {
            mmcache_gc();
        }
        if ($value === null) {
            @mmcache_rm($key);
        } else {
            mmcache_put($key, $value, $ttl);
        }
    } elseif (function_exists('apc_store')) {
        // An extended key is needed to counteract a bug in APC.
        if ($value === null) {
            apc_delete($key . 'smf');
        } else {
            apc_store($key . 'smf', $value, $ttl);
        }
    } elseif (function_exists('output_cache_put')) {
        output_cache_put($key, $value);
    } elseif (function_exists('xcache_set') && ini_get('xcache.var_size') > 0) {
        if ($value === null) {
            xcache_unset($key);
        } else {
            xcache_set($key, $value, $ttl);
        }
    } elseif (function_exists('fwrite')) {
        if ($value === null) {
            @unlink($cachedir . '/data_' . $key . '.php');
        } else {
            $fp = @fopen($cachedir . '/data_' . $key . '.php', 'w');
            if ($fp) {
                // Write the header.
                @flock($fp, LOCK_EX);
                fwrite($fp, '<' . '?' . 'php if (!defined(\'SMF\')) die; if (' . (time() + $ttl) . ' < time()) $expired = true; else{$expired = false; $value = \'' . addcslashes($value, '\\\'') . '\';}' . '?' . '>');
                @flock($fp, LOCK_UN);
                fclose($fp);
            }
        }
    }
    if (isset($db_show_debug) && $db_show_debug === true) {
        $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
    }
}
开发者ID:Kheros,项目名称:MMOver,代码行数:75,代码来源:Load.php

示例11: pmxCachePut

 function pmxCachePut($key, $value, $ttl, $useMember = false, $cleaner = null)
 {
     global $PortaMx_cache, $user_info;
     $st = microtime(true);
     if ($value === null && $cleaner !== null && $useMember) {
         $ckey = $PortaMx_cache['key'] . '-' . $cleaner . '-' . $key;
     } else {
         $ckey = $PortaMx_cache['key'] . ($useMember ? '-' . implode('_', $user_info['groups']) : '') . '-' . $key;
     }
     if (function_exists('zend_shm_cache_store')) {
         zend_shm_cache_store('PMX::' . $ckey, $value, $ttl);
     } elseif (function_exists('output_cache_put')) {
         output_cache_put($ckey, $value);
     }
     if ($value !== null) {
         $PortaMx_cache['vals']['saved'] += strlen($value);
     }
     $PortaMx_cache['vals']['time'] += microtime(true) - $st;
     // handle member groups key?
     if ($useMember && $cleaner === null) {
         pmxCacheMemGroupAcs();
     }
 }
开发者ID:thunderamur,项目名称:PortaMx-Virgo-2.0-Beta-2,代码行数:23,代码来源:SubsCache.php

示例12: save

 /**
  * Save some string datas into a cache record
  *
  * Note : $data is always "string" (serialization is done by the
  * core not by the backend)
  *
  * @param string $data data to cache
  * @param string $id cache id
  * @param array $tags array of strings, the cache record will be tagged by each string entry
  * *                  This option is not supported in this backend
  * @return boolean true if no problem
  */
 public function save($data, $id, $tags = array())
 {
     $result = output_cache_put($id, $data);
     if (count($tags) > 0) {
         foreach ($tags as $tag) {
             $tagid = self::TAGS_PREFIX . $tag;
             $old_tags = output_cache_get($tagid, $this->_directives['lifeTime']);
             if (!$old_tags) {
                 $old_tags = array();
             }
             $old_tags[$id] = 1;
             output_cache_put($tagid, $old_tags);
         }
         /*            if ($this->_directives['logging']) {
                         Zend_Log::log("Zend_Cache_Backend_ZendPlatform::save() : tags are unsupported by the Zend Platform backend", Zend_Log::LEVEL_WARNING);
         		}*/
     }
     return $result;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:31,代码来源:ZendPlatform.php

示例13: sugar_cache_put

/**
 * Put a value in the cache under a key
 *
 * @param String $key -- Global namespace cache.  Key for the data.
 * @param Serializable $value -- The value to store in the cache.
 */
function sugar_cache_put($key, $value)
{
    if (!$GLOBALS['external_cache_checked']) {
        check_cache();
    }
    if (EXTERNAL_CACHE_DEBUG) {
        echo "<HR>1 Adding key to APC cache {$key} with value ({$value})<HR>";
    }
    if (empty($value)) {
        $value = EXTERNAL_CACHE_NULL_VALUE;
    }
    if (EXTERNAL_CACHE_DEBUG) {
        echo "<HR>2 Adding key to APC cache {$key} with value ({$value})<HR>";
    }
    $GLOBALS['cache_local_store'][$key] = $value;
    if ($GLOBALS['external_cache_enabled']) {
        $external_key = $GLOBALS['sugar_config']['unique_key'] . $key;
        if ($GLOBALS['external_cache_type'] == 'zend') {
            output_cache_put($external_key, $value);
        } elseif ($GLOBALS['external_cache_type'] == 'apc') {
            $test_time = EXTERNAL_CACHE_INTERVAL_SECONDS;
            $return = apc_store($external_key, $value, $test_time);
            if (EXTERNAL_CACHE_DEBUG) {
                echo "<HR>Adding key to APC cache {$external_key} with value ({$value}) to be stored for {$test_time} seconds<HR>";
            }
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:livealphaprint,代码行数:34,代码来源:external_cache.php


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