- /*
- * 是否已经抢票
- */
- public function is_fight_tickets($fightticktes,$openid){
- $where['openid'] = $openid;
- $where["telephone"] = array('exp', 'is not NULL');
- $ticketsresults = $fightticktes ->where($where) -> find();
- ///判断是否已经购票
- if(!empty($ticketsresults)){
- return $ticketsresults;
- }else{
- $allowtickets = $this->allowtickets("");
- ///返回数字 或者 false
- if($allowtickets){
- ////插入
- }else{
- }
- }
- }
- //允许
- public function allowtickets($openid){
- $Cache = Cache::getInstance('Redis');
- $result =$Cache->lpop("fight_tickets:ticketlist");
- return $result;
- }
- public function createtickets(){
- $Cache = Cache::getInstance('Redis');
- ///$hashset = "fight_tickets:";
- for($i=10;$i<20000;$i++){
- $Cache->rpush("fight_tickets:ticketlist",$i);
- echo $i;
- }
- SADD key member [member ...]
- 将一个或多个 member 元素加入到集合 key 当中,已经存在于集合的 member 元素将被忽略。
- 假如 key 不存在,则创建一个只包含 member 元素作成员的集合。
- 当 key 不是集合类型时,返回一个错误。
- 返回值:
- 被添加到集合中的新元素的数量,不包括被忽略的元素。
- # 添加单个元素
- redis> SADD bbs "discuz.net"
- (integer) 1
- # 添加重复元素
- redis> SADD bbs "discuz.net"
- (integer) 0
- # 添加多个元素
- redis> SADD bbs "tianya.cn" "groups.google.com"
- (integer) 2
- /*
- 从list 头部压入一个元素 先进后出
- lpush mylist "word"
- lpush mylist "ehll"
- lrange mylist 0 -1 显示 ehll word
- */
- /*
- rpop 从list 尾部删除一个元素,并返回删除的元素
- ///rpop mylist
- //$times = $Cache->get($hashset);
- //$key = "集合数据iD";
- //$Cache->zrem($hashset,$key);*/
- }
- //该片段来自于http://www.codesnippet.cn/detail/1609201410437.html
来源: http://www.codesnippet.cn/detail/1609201410437.html