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); }
function SaeMemcacheIncrement($key, $value) { //如果长度超出,则取末尾的234位 if (strlen($key) > 234) { $key = substr($key, -234); } $mmc = memcache_init(); if ($mmc == false) { return false; } else { return memcache_increment($mmc, $key, $value); } //如果指定的key对应的元素不是数值类型并且不能被转换为数值, 会将此值修改为value //memcache_increment()不会在key对应元素不存在时创建元素 }
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; $errors = []; if (is_null($item_name)) { $errors[] = 'Non-empty name required'; } else { $item_name = htmlspecialchars(trim($item_name)); if ($item_name === '') { $errors[] = 'Non-empty name required'; } } if (is_null($item_price) || !preg_match("/^\\d+([.,]\\d{1,2})?\$/", $item_price)) { $errors[] = 'Incorrect price number'; } if (is_null($item_description)) { $errors[] = 'Incorrect description'; } else { $item_description = htmlspecialchars(trim($item_description)); } if (!empty($errors)) { api_echo_as_json($errors, 'errors', RESPONSE_STATUS_FAIL); return; } $item_price = str_replace(',', '.', $item_price); if (is_null($item_img)) { $item_img = "Null"; } 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'); } api_echo_as_json('Item created', 'msg'); }
public function testIncrementNonExistingValue() { $memcache = new Memcache(); $request = new MemcacheIncrementRequest(); $request->setKey("key"); $request->setDelta(5); $response = new MemcacheIncrementResponse(); $this->apiProxyMock->expectCall('memcache', 'Increment', $request, $response); $this->assertFalse(memcache_increment($memcache, "key", 5)); $this->apiProxyMock->verify(); }
function MCache_increment($mcConnect, $key, $value) { return memcache_increment($mcConnect, $key, $value); }
/** * @see http://php.net/manual/ru/memcache.increment.php * * @param array &$Memcached объект мемкеша * @param string $key ключ инкремента * @param int $value стартовое значение * * @return int|bool новое значение ключа или false при ошибке */ function increment(array &$Memcached, $key, $value = 1) { return memcache_increment(getMemcacheObject($Memcached), $key, $value); }
public function increment($key = '', $increment = 1) { return memcache_increment($key, $increment); }
/** * Increment item's value * * @param string $ns Key namespace (read from config) * @param string $key Key name * @param int $value Increment the item by value. Optional and defaults to 1. * @return mixed New item's value on success or FALSE on failure. */ public function inc($ns, $key, $val = 1) { $this->_checkNs($ns); $key = $this->_keyNs[$ns]['value'] . ':' . $key; return memcache_increment($this->_conn($ns), $key, $val); }
/** * Increment the value of an item in the cache. * * @param string $key * @param mixed $value * @return int|bool */ public function increment($key, $value = 1) { return memcache_increment($this->memcache, $key, $value); }
function inc($name, $step = 1) { return memcache_increment($this->_mamcache, $this->prefix . $name, $step); }
public static function inc($key) { return \memcache_increment(self::$connection, $key); }
$mailprefix[] = $monitorPhone['mailprefix']; } //短信接口 $url = 'http://202.108.35.62/serverguard/SendV2.php?user=general&password=nbaa8a2a1d5b981deacb8c1e2general&phone=' . urlencode(implode(',', $phone)) . '&msg=' . urlencode($messageSend) . '&level=' . urlencode($submodule['level']); _http_get($url, array('timeout' => 1), $info); $url = 'http://i.alarm.mix.sina.com.cn/?s=client&a=message&format=json&to=' . urlencode(implode(',', $mailprefix)) . '&content=' . urlencode($messageSend) . '&level=' . urlencode($submodule['level']); _http_get($url, array('timeout' => 1), $info); memcache_delete($mc, $smsMsgKey); echo 'sms'; //exit('sms'); } } $mailMsgKey = implode('|', array('mail_msg', $submodule['id'])); $mailMsgInitRes = memcache_add($mc, $mailMsgKey, 1, false, 3600); if ($mailMsgInitRes === false) { $mailMsgCount = memcache_increment($mc, $mailMsgKey, 1); } else { $mailMsgCount = 1; } echo $mailMsgCount; $mailWarningKey = implode('|', array('mail', $submodule['id'])); if ($mailMsgCount >= $submodule['mail_limit'] && $submodule['mail_status']) { //sendmail $mailLock = memcache_add($mc, $mailWarningKey, 1, false, 600); if ($mailLock === true) { $arr = $matches = array(); preg_match("/^SELECTED:\\[(.*)\\]\$/", $project['monitors'], $matches); $str = str_replace('\'', '"', "[" . $matches[1] . "]"); $projectUids = json_decode($str, true); $arr = $matches = array(); if (!empty($submodule['monitors'])) {
function increment_var($var, $value) { $memcached = __memcache(); if ($value > 0) { $memcached = memcache_increment($memcached, $var, $value); if ($memcached) { echo "Variable {$var} was incremented with {$value}"; } } }