cyrilcao

A new day has come
Home » Latest Post » 第1733天

redis count

   <?php
    include_once ('s/RedisCounter.class.php');        
    $oRedisCounter = new RedisCounter();     
    // 定义保存计数的健值
    $key = 'mycounter';     
    // 执行自增计数,获取当前计数,重置计数
    //echo $oRedisCounter->incr($key).PHP_EOL; // 1
    //echo $oRedisCounter->get($key).PHP_EOL; // 0 
   ?>    
<?php
class RedisCounter
{
    private $_config;
    private $redis = null;

    public function flush()
    {
        return $this->redis->flushDb();
    }
 
    /**
     * 初始化
     * @param Array $config redis连接设定
     */
    public function __construct(){ 
        $this->_config =array(
                            'host' => 'localhost',
                            'port' => 6379,
                            'index' => 0,
                            'auth' => '',
                            'timeout' => 1,
                            'reserved' => NULL,
                            'retry_interval' => 100,
                        );;
        $this->_redis = $this->connect();
    }
 
    /**
     * 执行自增计数并获取自增后的数值
     * @param  String $key  保存计数的键值
     * @param  Int    $incr 自增数量,默认为1
     * @return Int
     */
    public function incr($key, $incr=1){
        return intval($this->_redis->incr($key, $incr));
    }
 
    /**
     * 获取当前计数
     * @param  String $key 保存计数的健值
     * @return Int
     */
    public function get($key){
        return intval($this->_redis->get($key));
    }
 
    /**
     * 重置计数
     * @param  String  $key 保存计数的健值
     * @return Int
     */
    public function reset($key){
        return $this->_redis->delete($key);
    }
 
    /**
     * 创建redis连接
     * @return Link
     */
    private function connect(){
        try{
            $redis = new Redis();
            $redis->connect($this->_config['host'],$this->_config['port'],$this->_config['timeout'],$this->_config['reserved'],$this->_config['retry_interval']);
            /*
            if(empty($this->_config['auth'])){
                $redis->auth($this->_config['auth']);
            }
            */
            $redis->select($this->_config['index']);
        }catch(RedisException $e){
            throw new Exception($e->getMessage());
            return false;
        }
        return $redis;
    }

    
}
?>

Redis for PhP 开启

https://blog.csdn.net/Fly_hps/article/details/82970297?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-4.control&dist_request_id=1328767.73733.16177267712981137&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-4.control

127.0.0.1:6379> ping
PONG
127.0.0.1:6379> keys *
1) "neteasepic18962177532894457"
2) "neteaseurl258416"
3) "k2"
4) "neteasepic109951164912253150"
5) "neteaselrc165340"
6) "neteaseurl141288"
7) "neteasepic109951163083269878"
8) "neteaselrc351224"
9) "neteaselrc77103"
10) "neteaseurl77103"
11) "neteaseurl5249178"
12) "neteasepic109951164176658680"
13) "neteaselrc258416"
14) "neteaselrc141288"
15) "neteaseurl165340"
16) "neteaseplaylist95102196"
17) "neteasepic109951163167402154"
18) "neteaseurl351224"
19) "neteaseurl258542"
20) "neteasepic19000660439853455"
21) "k1"
22) "neteasepic109951163368468453"
23) "neteaselrc258542"
24) "neteaselrc5249178"
127.0.0.1:6379>

Phpinfo

aplayer meting pjax

1

<div class="aplayer no-destroy" 

data-id="95102196" 
data-server="netease" 
data-type="playlist" 
data-auth="c35aadf2103e95259b445b095c7e4fde" 
data-theme="#ad7a86" 
data-preload="auto" 
data-autoplay="true" 
data-listmaxheight="340px" 
data-order="random" 
data-list-folded="true" 
data-fixed="true">

</div>


   try {
            aplayers[i].destroy();
        } catch (e) {
            console.log(e);
        if(!aplayers[i].container.classList.contains("no-destroy")){
            try {
                aplayers[i].destroy();
            } catch (e) {
                console.log(e);
            }

##pjax中重载函数
loadMeting();

标题背景图片

.head {

background-color: #333639;
color: rgba(255,255,255,.5);
padding: 40px 25px 100px 25px;
text-shadow: 4px 3px 0 #2b2b2b, 9px 8px 0 rgba(0,0,0,0.15);
background-image: url(img/5fd.jpg);
background-repeat: no-repeat;
background-size: 100% 100%;

}

left banner

<style>
            #sb-aside .wrapper:hover {
            background: url("<?php $this->options->themeUrl('s/img/snow.gif'); ?>");
            background-size: cover;
            color: #32cd54;
            }
            #sb-aside {
                width: 80%;
                margin: 30px auto;
                font-size: 12px;
                color: #777;
            }
            #sb-aside .wrapper{
                width: 80%;
                margin: 30px auto;
                font-size: 12px;
                color: #777;
            }
            #sb-aside .avatar {
                position: relative;
                display: block;
                white-space: nowrap;
                border-radius: 500px;
            }
            .img-circle {
                border-radius: 50%;
            }
        </style>
        <div class="sb-aside" id="sb-aside">
            <div class="wrapper">
                <div ui-nav="">
                    <a href="/index.html">
                    <span class="avatar">
                        <img src="<?php $this->options->themeUrl('s/img/avatar.jpg'); ?>" class="img-full img-circle normal-shadow">
                    </span>
              </a>
                </div>
              <a href="#" data-toggle="dropdown" class="dropdown-toggle hidden-folded  ">
                <span class="clear">
                  <span class="text-muted text-xs block">万物皆可萌</span>
                   <span class="text-muted text-xs block"> <p>早上好,永远年轻,永远热泪盈眶</p></span>
                </span>
              </a>            
            </div>
      </div>
  Life is fantastic
More
© 2025 cyrilcao版权所有 | 备案号-沪ICP备2021009045号-1
驱动Typecho - touchit主题 访问次数:254314