Esempio n. 1
0
function process_request()
{
    $item_id = isset($_GET['item_id']) ? intval($_GET['item_id']) : false;
    if ($item_id == false || $item_id <= 0) {
        api_wrong_args();
        return;
    }
    $item = db_get_item($item_id);
    if (!$item) {
        api_echo_as_json("Item not found", 'msg');
        return;
    }
    db_delete_item($item_id);
    $mc_handler = memcache_connect('localhost');
    pagination_rebuild_ids($mc_handler, $item['id']);
    pagination_rebuild_prices($mc_handler, $item['price']);
    if (memcache_get($mc_handler, 'total_rows') !== false) {
        memcache_decrement($mc_handler, 'total_rows');
    }
    api_echo_as_json('Item deleted', 'msg');
    memcache_delete($mc_handler, "item_" . $item_id);
}
Esempio n. 2
0
 public function testDecrementSuccess()
 {
     $memcache = new Memcache();
     $request = new MemcacheIncrementRequest();
     $request->setKey("key");
     $request->setDelta(4);
     $request->setDirection(MemcacheIncrementRequest\Direction::DECREMENT);
     $response = new MemcacheIncrementResponse();
     $response->setNewValue(8);
     $this->apiProxyMock->expectCall('memcache', 'Increment', $request, $response);
     $this->assertEquals(8, memcache_decrement($memcache, "key", 4));
     $this->apiProxyMock->verify();
 }
Esempio n. 3
0
function MCache_decrement($mcConnect, $key, $value)
{
    return memcache_decrement($mcConnect, $key, $value);
}
Esempio n. 4
0
 public function decrement($key = '', $decrement = 1)
 {
     memcache_decrement($key, $decrement);
 }
Esempio n. 5
0
function SaeMemcacheDecrement($key, $value)
{
    //如果长度超出,则取末尾的234位
    if (strlen($key) > 234) {
        $key = substr($key, -234);
    }
    $mmc = memcache_init();
    if ($mmc == false) {
        return false;
    } else {
        return memcache_decrement($mmc, $key, $value);
    }
    //如果指定的key对应的元素不是数值类型并且不能被转换为数值, 会将此值修改为0
    //memcache_decrement()不会在key对应元素不存在时创建元素
}
Esempio n. 6
0
 /**
  * Decrement item's value
  *
  * @param	string	$ns			Key namespace (read from config)
  * @param	string	$key		Key name
  * @param	int		$value 		Decrement the item by value. Optional and defaults to 1.
  * @return	mixed				New item's value on success or FALSE on failure.
  */
 public function dec($ns, $key, $val = 1)
 {
     $this->_checkNs($ns);
     $key = $this->_keyNs[$ns]['value'] . ':' . $key;
     return memcache_decrement($this->_conn($ns), $key, $val);
 }
Esempio n. 7
0
 /**
  * Decrement the value of an item in the cache.
  *
  * @param  string  $key
  * @param  mixed   $value
  * @return int|bool
  */
 public function decrement($key, $value = 1)
 {
     return memcache_decrement($this->memcache, $key, $value);
 }
Esempio n. 8
0
 function dec($name, $step = 1)
 {
     return memcache_decrement($this->_mamcache, $this->prefix . $name, $step);
 }
Esempio n. 9
0
 public static function dec($key)
 {
     return \memcache_decrement(self::$connection, $key);
 }
Esempio n. 10
0
function decrement_var($var, $value)
{
    $memcached = __memcache();
    if ($value > 0) {
        $memcached = memcache_decrement($memcached, $var, $value);
        if ($memcached) {
            echo "Variable {$var} was decremented with {$value}";
        }
    }
}