本文整理汇总了PHP中memcache_get函数的典型用法代码示例。如果您正苦于以下问题:PHP memcache_get函数的具体用法?PHP memcache_get怎么用?PHP memcache_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了memcache_get函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: process_request
function process_request()
{
$item_name = isset($_POST['item_name']) ? $_POST['item_name'] : null;
$item_price = isset($_POST['item_price']) ? $_POST['item_price'] : null;
$item_description = isset($_POST['item_description']) ? $_POST['item_description'] : null;
$item_img = isset($_POST['item_img']) ? $_POST['item_img'] : null;
if (is_null($item_name)) {
die;
} else {
$item_name = htmlspecialchars(trim($item_name));
if ($item_name === '') {
die;
}
}
if (is_null($item_price) || !preg_match("/^\\d+([.,]\\d{1,2})?\$/", $item_price)) {
die;
}
$item_price = str_replace(',', '.', $item_price);
if (is_null($item_description)) {
die;
} else {
$item_description = htmlspecialchars(trim($item_description));
}
if (is_null($item_img)) {
$item_img = "Null";
}
$id = db_insert_item($item_name, $item_description, $item_price, $item_img);
$mc_handler = memcache_connect('localhost');
if (memcache_get($mc_handler, 'total_rows') !== false) {
memcache_increment($mc_handler, 'total_rows');
pagination_rebuild_ids($mc_handler, $id);
pagination_rebuild_prices($mc_handler, $item_price);
}
header('Location: /view_item.php?id=' . $id);
}
开发者ID:plFlok,项目名称:vk_test_task,代码行数:35,代码来源:create_item_tech.php
示例2: cache_get
function cache_get($key)
{
$connection = cache_connect();
$data = memcache_get($connection, (string) $key);
memcache_close($connection);
return $data;
}
开发者ID:smarty-kiki,项目名称:frame,代码行数:7,代码来源:cache.php
示例3: pdb_get_data
function pdb_get_data($key, $provider, $arguments = [])
{
$mc_handler = memcache_pconnect(MC_HOST);
$value = memcache_get($mc_handler, $key);
if ($value !== false) {
return $value;
} else {
$locking_key = 'lock_' . $key;
$locking_value = microtime(true);
for ($i = 0; $i < MC_LOCK_DELAY * 1000 / MC_SLEEP_TIME + 1; $i++) {
$lock = memcache_add($mc_handler, $locking_key, $locking_value, 0, MC_LOCK_DELAY);
if ($lock) {
$value = call_user_func_array($provider, $arguments);
memcache_set($mc_handler, $key, $value);
memcache_delete($mc_handler, $locking_key);
return $value;
} else {
usleep(MC_SLEEP_TIME);
$value = memcache_get($mc_handler, $key);
if ($value != false) {
return $value;
}
}
}
}
return call_user_func_array($provider, $arguments);
}
开发者ID:plFlok,项目名称:vk_test_task,代码行数:27,代码来源:db_cache_proxy.php
示例4: requeue_snapshot
public function requeue_snapshot()
{
ignore_user_abort(true);
header("Connection: Close");
flush();
ob_end_flush();
$m = memcache_connect('127.0.0.1', 11211);
$urlkey = sha1($this->snapshot_url);
if (isset($_GET['requeue']) && 'true' != $_GET['requeue']) {
if (memcache_get($m, $urlkey)) {
die;
}
}
memcache_set($m, $urlkey, 1, 0, 300);
$requeue_url = self::renderer . "/queue?url=" . rawurlencode($this->snapshot_url) . "&f=" . urlencode($this->snapshot_file);
$retval = file_get_contents($requeue_url);
$tries = 1;
while (false === $retval && $tries <= 5) {
sleep(1);
// in the event that the failed call is due to a mShots.js service restart,
// we need to be a little patient as the service comes back up
$retval = file_get_contents($requeue_url);
$tries++;
}
}
开发者ID:nexusthemes,项目名称:mShots,代码行数:25,代码来源:class-mshots.php
示例5: memcache_safeadd
function memcache_safeadd(&$memcache_obj, $key, $value, $flag, $expire)
{
if (memcache_add($memcache_obj, $key, $value, $flag, $expire)) {
return $value == memcache_get($memcache_obj, $key);
}
return FALSE;
}
开发者ID:JeremyHutchings,项目名称:OffLog,代码行数:7,代码来源:offLogWorker.php
示例6: cache_get
function cache_get($key)
{
if (!cache_connect()) {
return false;
}
return memcache_get(object('memcache'), $GLOBALS['config']['service']['server'] . '/' . $key);
}
开发者ID:hcopr,项目名称:Hubbub,代码行数:7,代码来源:genlib.php
示例7: getItem
public function getItem($key)
{
if (empty($key)) {
throw new CacheException('CACHE ERROR:key is empty');
}
return memcache_get($this->cache, $key, self::COMP);
}
开发者ID:tiger2soft,项目名称:LycPHP,代码行数:7,代码来源:Memcache.class.php
示例8: db_mysqli_query_fetch_list
function db_mysqli_query_fetch_list($mysqli, $query, $MYSQLI_TYPE)
{
$config = getConfig();
$params = $config['memcache'];
$memcache = memcache_connect($params['host'], $params['port']);
$memcacheQueryKey = 'QUERY' . $query['slow'];
$data = memcache_get($memcache, $memcacheQueryKey);
if (!empty($data)) {
} else {
if (!empty($query['fast'])) {
$result = mysqli_query($mysqli, $query['fast']);
} else {
$result = mysqli_query($mysqli, $query['slow']);
}
$data = [];
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
$data[] = $row;
}
//another proc
/* $pid = pcntl_fork();
if ($pid == 0) {*/
memcache_set($memcache, $memcacheQueryKey, $data, 0, 60 * 10);
/* posix_kill(posix_getpid(), SIGTERM);
}*/
}
memcache_close($memcache);
return $data;
}
开发者ID:fedotovaleksandr,项目名称:vkTest,代码行数:28,代码来源:db_mysqli_query_fetch_list.php
示例9: get
public function get($key)
{
$this->check();
if (($ret = memcache_get($this->connection, $key)) === false) {
return false;
}
return $ret;
}
开发者ID:jkinner,项目名称:ringside,代码行数:8,代码来源:CacheMemcache.php
示例10: memcache_version_get
function memcache_version_get($memcache_obj, $key)
{
global $config;
if ($config['mcache']['version'] == 0) {
return memcache_get($memcache_obj, $key);
} else {
return $memcache_obj->get($key);
}
}
开发者ID:laiello,项目名称:po-php-fwlite,代码行数:9,代码来源:memcache.func.php
示例11: fetch
/**
* Retrieve an item from the cache.
*
* @param string The name of the cache
* @param boolean True if we should do a hard refresh
* @return mixed Cache data if successful, false if failure
*/
function fetch($name, $hard_refresh = false)
{
$data = memcache_get($this->memcache, $this->unique_id . "_" . $name);
if ($data === false) {
return false;
} else {
return $data;
}
}
开发者ID:benn0034,项目名称:SHIELDsite2.old,代码行数:16,代码来源:memcache.php
示例12: sessionRead
/**
* Reads data from doctrine tables and return its content
* @param string $id
* @throws AppKitDoctrineSessionStorageException
*/
public function sessionRead($id)
{
$session = memcache_get($this->memcache, $this->prefix . $this->getParameter('session_name') . ":" . $id);
if (!$session) {
memcache_add($this->memcache, $this->prefix . $this->getParameter('session_name') . ":" . $id, "");
return '';
}
return $session;
}
开发者ID:philippjenni,项目名称:icinga-web,代码行数:14,代码来源:AppKitMemcacheSessionStorage.class.php
示例13: get
public function get($key)
{
$expire = memcache_get($this->mmc, $this->group . '_' . $this->ver . '_time_' . $key);
if (intval($expire) > time()) {
return memcache_get($this->mmc, $this->group . '_' . $this->ver . '_' . $key);
} else {
return false;
}
}
开发者ID:lerre,项目名称:canphp,代码行数:9,代码来源:SaeMemcacheDriver.php
示例14: cache_get
function cache_get($key, $defval = false)
{
global $_mch;
$val = memcache_get($_mch, $key);
if (!$val) {
return $defval;
}
return unserialize($val);
}
开发者ID:senko,项目名称:rfx,代码行数:9,代码来源:cache.php
示例15: is_memcache_ok
function is_memcache_ok()
{
$mmc = @memcache_init();
if ($mmc == FALSE) {
return FALSE;
} else {
memcache_set($mmc, "dilicms_install_test", "dilicms");
return memcache_get($mmc, "dilicms_install_test") == 'dilicms';
}
}
开发者ID:leamiko,项目名称:DiliCMS,代码行数:10,代码来源:install_helper.php
示例16: get_by_key_name
public static function get_by_key_name($key_name)
{
$link = memcache_init();
if (!$key_name) {
return false;
}
$data = memcache_get($link, $key_name);
$new_obj = new Game($key_name, $data);
return $new_obj;
}
开发者ID:alianwu,项目名称:sae-channel-examples,代码行数:10,代码来源:game.php
示例17: get
public function get($name)
{
if (!is_resource($this->memcache)) {
throw new \Exception("Memcached can't connect.");
}
$data = memcache_get($this->memcache, $name);
if ($data) {
return $data;
} else {
throw new \Exception("cache not exists.");
}
}
开发者ID:glzaboy,项目名称:fastlib,代码行数:12,代码来源:sae.php
示例18: testFlush
public function testFlush()
{
parent::testFlush();
$mmc = memcache_connect($this->mmhost, $this->mmport);
$this->assertTrue(memcache_get($mmc, 'flush1DataKey'));
$this->assertTrue(memcache_get($mmc, 'flush2DataKey'));
$this->assertTrue(memcache_get($mmc, 'flush3DataKey'));
$this->assertTrue(jCache::flush($this->profile));
$this->assertFalse(memcache_get($mmc, 'flush1DataKey'));
$this->assertFalse(memcache_get($mmc, 'flush2DataKey'));
$this->assertFalse(memcache_get($mmc, 'flush3DataKey'));
}
开发者ID:hadrienl,项目名称:jelix,代码行数:12,代码来源:jcache.memcache22.html_cli.php
示例19: get
/**
* Returns data from cache or NULL if data is missing or expired.
*
* @param string $ns Key namespace (read from config)
* @param string $key Key name
* @return mixed
*/
public function get($ns, $key)
{
PROFILER_IN('Cache-get');
$this->_checkNs($ns);
$key = $this->_keyNs[$ns]['value'] . ':' . $key;
$res = memcache_get($this->_conn($ns), $key);
if (FALSE === $res) {
$res = NULL;
}
PROFILER_OUT('Cache-get');
return $res;
}
开发者ID:evilgeny,项目名称:bob,代码行数:19,代码来源:Facade.class.php
示例20: register_static_get
static function register_static_get($key)
{
$mmc = memcache_init();
if ($mmc == false) {
echo "那个坑爹的Memcache加载失败啦!笨蛋!\n";
} else {
if ($out = memcache_get($mmc, 'tk_' . $key)) {
return $out;
} else {
return false;
}
}
}
开发者ID:acsiiii,项目名称:leeeframework,代码行数:13,代码来源:data_use.php
注:本文中的memcache_get函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论