/**
 +----------------------------------------------------------
 * 架构函数
 * 取得DB类的实例对象
 +----------------------------------------------------------
 * @param string $name 模型名称
 * @param mixed $connection 数据库连接信息
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 */
 public function __construct()
 {
     // 数据库初始化操作
     // 当前模型数据库连接信息
     if (!self::$socket) {
         self::$socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
         if (self::$socket < 1) {
             return false;
         }
         $source = @socket_connect(self::$socket, self::$addr, self::$port);
         if ($source < 1) {
             if (self::$debug == true) {
                 $this->customError("connect", "Unable to connect the server side");
             } else {
                 return false;
             }
         }
     }
 }
Exemple #2
0
<?php

include "xuncache.class.php";
$xuncache = new xuncache();
//字符串类型操作
//添加数据
$string = $xuncache->key("xuncache")->add("xuncache");
dump($string);
//bool(true)
//查找数据
$string = $xuncache->key("xuncache")->find();
dump($string);
//string(8) "xuncache"
//删除数据
$status = $xuncache->key("xuncache")->del();
dump($status);
//bool(true)
//数组操作(仅支持二位数组)
$array['name'] = "xuncache";
$array['version'] = "beta";
//增加数组
$status = $xuncache->key("array")->zadd($array);
dump($status);
//bool(true)
//查找数组
$array = $xuncache->key("array")->zfind();
dump($array);
/*  array(2) {
 *      ["name"] => string(8) "xuncache"
 *      ["version"] => string(3) "beta"
 *  }