本文整理汇总了PHP中memcache_get函数的典型用法代码示例。如果您正苦于以下问题:PHP memcache_get函数的具体用法?PHP memcache_get怎么用?PHP memcache_get使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了memcache_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: cache_get
function cache_get($key)
{
$connection = cache_connect();
$data = memcache_get($connection, (string) $key);
memcache_close($connection);
return $data;
}
示例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);
}
示例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++;
}
}
示例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;
}
示例6: cache_get
function cache_get($key)
{
if (!cache_connect()) {
return false;
}
return memcache_get(object('memcache'), $GLOBALS['config']['service']['server'] . '/' . $key);
}
示例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);
}
示例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;
}
示例9: get
public function get($key)
{
$this->check();
if (($ret = memcache_get($this->connection, $key)) === false) {
return false;
}
return $ret;
}
示例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);
}
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例14: cache_get
function cache_get($key, $defval = false)
{
global $_mch;
$val = memcache_get($_mch, $key);
if (!$val) {
return $defval;
}
return unserialize($val);
}
示例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';
}
}