• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP mmcache_put函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: write

 /**
  * write template to cache
  *
  * @access	public
  * @param	string		cache key
  * @param	array		templates to store
  * @return	boolean		true on success
  */
 function write($key, $templates)
 {
     if (!function_exists('mmcache_lock')) {
         return false;
     }
     mmcache_lock($key);
     if ($this->getParam('lifetime') == 'auto') {
         mmcache_put($key, serialize($templates));
     } else {
         mmcache_put($key, serialize($templates), $this->getParam('lifetime') * 60);
     }
     mmcache_unlock($key);
     return true;
 }
开发者ID:jwest00724,项目名称:Joomla-1.0,代码行数:22,代码来源:MMCache.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: 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


示例4: set

 /**
  * set value of variable in shared mem
  *
  * @param string $name  name of the variable
  * @param string $value value of the variable
  * @param int $ttl (optional) time to life of the variable
  *
  * @return bool true on success
  * @access public
  */
 function set($name, $value, $ttl = 0)
 {
     mmcache_lock($name);
     return mmcache_put($name, $value, $ttl);
 }
开发者ID:TiMoChao,项目名称:xingfu,代码行数:15,代码来源:Mmcache.php


示例5: set

 function set($key, $value, $exptime = 0)
 {
     mmcache_put($key, serialize($value), $exptime);
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:5,代码来源:BagOStuff.php


示例6: 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


示例7: 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


示例8: flush

 /**
  * (Plug-in replacement for memcache API) Remove all data from the persistant cache.
  */
 function flush()
 {
     global $ECACHE_OBJECTS;
     $ECACHE_OBJECTS = array();
     if (function_exists('eaccelerator_rm')) {
         foreach (array_keys($ECACHE_OBJECTS) as $obkey) {
             eaccelerator_rm($obkey);
         }
     } elseif (function_exists('mmcache_rm')) {
         foreach (array_keys($ECACHE_OBJECTS) as $obkey) {
             mmcache_rm($obkey);
         }
     }
     if (function_exists('eaccelerator_put')) {
         eaccelerator_put(get_file_base() . 'ECACHE_OBJECTS', $ECACHE_OBJECTS, 0);
     } elseif (function_exists('mmcache_put')) {
         mmcache_put(get_file_base() . 'ECACHE_OBJECTS', $ECACHE_OBJECTS, 0);
     }
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:22,代码来源:caches_eaccelerator.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP mnet_debug函数代码示例发布时间:2022-05-15
下一篇:
PHP mmcache_get函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap