解密函数
@param  string $entxt 需要解密的字符串
@param  string $key 密钥
@param  int    $expire 有效时长，单位为秒，默认0不限制时长
@return string 字符串类型的返回结果
12236
public function decrypt($entxt, $key=null, $expire=null)
    {
        $key = $key ?: $this->options['key'];
        if (is_null($expire)) {
            $expire = $this->options['expire'];
        }
        return $this->getAdapter()->decrypt($entxt, $key, $expire);
    }
998888
public static function encrypt($str,$key,$expire=0){
        $expire = sprintf('%010d', $expire ? $expire + time():0);
        $r = md5($key);
        $c = 0;
        $v = "";
        $str    =   $expire.$str;
		$len = strlen($str);
		$l = strlen($r);
        for ($i=0;$i<$len;$i++){
         if ($c== $l) $c=0;
         $v .= substr($r,$c,1) .
             (substr($str,$i,1) ^ substr($r,$c,1));
         $c++;
        }
        return self::ed($v,$key);
    }
395989
public function expiresAt($key, $time = 0)
    {
        $expire = $time - time();

        return $this->redis->expire($key, $expire);
    }
1198427
public function toExt($data, $key = null, $array = false)
	{
		return $this->to(self::EXT, $data, $key, $array);
	}
685828
public function getExpiry($key)
    {
        $key = $this->getPrefix().$key;
        if (!$this->isInCache($key)) {
            return false;
        }

        return $this->fetchExpirationFromCache($key);
    }
538591
public function set($key, $value, $expire = 0)
    {
        return $this->setItem($key, $value, time(), $expire);
    }
927450
protected function getExpireTime($expire)
    {
        if ($expire instanceof \DateTime) {
            $expire = $expire->getTimestamp() - time();
        }

        return (int) $expire;
    }
191998
public function write($key, $value, $expire = null) 
    {
        if (!$this->enabled) {
            return ;
        }

        if ($expire === null) {
            $expire = $this->expire;
        }
        
        $data = [
            'time'   => time(),
            'expire' => time() + $expire,
            'value'  => $value,
        ];
    
        $this->stats['execTimes'] ++;
        $this->stats['writeTimes'] ++;            
        $this->stats['writeSize'] += strlen(var_export($value, true))/1024;
        $this->temp[$key] = $data;
        
        try {
            $this->waitUnlock($key);
            $this->lock($key);
            $this->store($key, $data);
            $this->unlock($key);
        } catch (\wf\cache\Exception $e) {
            $this->unlock($key);
            throw $e;
        }
    }
565258
public function decrypt($ciphertxt, $key = '', $ttl = 0)
    {
        if (empty($ciphertxt)) return $ciphertxt;
        if (empty($key)) $key = md5($this->key);
    
        $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.";
        $ikey ="-x6g6ZWm2G9g_vr0Bo.pOq3kRIxsZ6rm";
        $knum = 0;$i = 0;
        $tlen = @strlen($ciphertxt);
        while(isset($key{$i})) $knum +=ord($key{$i++});
        $ch1 = @$ciphertxt{$knum % $tlen};
        $nh1 = strpos($chars,$ch1);
        $ciphertxt = @substr_replace($ciphertxt,'',$knum % $tlen--,1);
        $ch2 = @$ciphertxt{$nh1 % $tlen};
        $nh2 = @strpos($chars,$ch2);
        $ciphertxt = @substr_replace($ciphertxt,'',$nh1 % $tlen--,1);
        $ch3 = @$ciphertxt{$nh2 % $tlen};
        $nh3 = @strpos($chars,$ch3);
        $ciphertxt = @substr_replace($ciphertxt,'',$nh2 % $tlen--,1);
        $nhnum = $nh1 + $nh2 + $nh3;
        $mdKey = substr(md5(md5(md5($key.$ch1).$ch2.$ikey).$ch3),$nhnum % 8,$knum % 8 + 16);
        $tmp = '';
        $j=0; $k = 0;
        $tlen = @strlen($ciphertxt);
        $klen = @strlen($mdKey);
        for ($i=0; $i<$tlen; $i++) {
            $k = $k == $klen ? 0 : $k;
            $j = strpos($chars,$ciphertxt{$i})-$nhnum - ord($mdKey{$k++});
            while ($j<0) $j+=64;
            $tmp .= $chars{$j};
        }
        $tmp = str_replace(array('-','_','.'), array('+','/','='), $tmp);
        $tmp = trim(base64_decode($tmp));
        
        if (preg_match("/\d{10}_/s", substr($tmp,0,11))){
            if ($ttl > 0 && (time() - substr($tmp,0,11) > $ttl)) {
                $tmp = null;
            }else{
                $tmp = substr($tmp, 11);
            }
        }
        return $tmp;
    }
187420
public function store( $key, $var, $expire = 0 )
    {
        if ( strlen( $key ) > self::MAX_KEY_LENGTH )
        {
            throw new ezcCacheInvalidKeyException( $key, 'Length > ' . self::MAX_KEY_LENGTH . '.' );
        }

        // protect our data by wrapping it in an object
        $data = new ezcCacheMemoryVarStruct( $key, $var, $expire );
        $compressed = ( $this->options->compressed === true ) ? MEMCACHE_COMPRESSED : false;
        return $this->memcache->set( $key, $data, $compressed, $expire );
    }
1065536
final public function expireat($key, $ttl) {
		$res = $this->connection->expireat($key, $ttl);
		self::$logger->info(sprintf(
			"Redis: expireat %s: %s.", $key, $ttl));
		return $res;
	}
1308219
public function set($key, $value, $expire = 600) {
        $this->redis->setex($this->formatKey($key), $expire, $this->formatValue($value));
    }
1344811
public function cache($key, $expires = null) {
        if ($this->getType() !== self::SELECT) {
            return $this;
        }

        $this->_cacheKey = $key;
        $this->_cacheLength = $expires;

        return $this;
    }
928021
protected static function getExpire(int $filemtime, int $expire): int {
		if ($expire === -1)
			return -1;
		$time = $filemtime + $expire - time();
		return ($time > 0) ? $time : 0;
	}
908294
public static function encrypt($str, $key,$expire=0) {
        $expire = sprintf('%010d', $expire ? $expire + time():0);
        $str    =   $expire.$str;
        $v = self::str2long($str, true);
        $k = self::str2long($key, false);
        $n = count($v) - 1;

        $z = $v[$n];
        $y = $v[0];
        $delta = 0x9E3779B9;
        $q = floor(6 + 52 / ($n + 1));
        $sum = 0;
        while (0 < $q--) {
            $sum = self::int32($sum + $delta);
            $e = $sum >> 2 & 3;
            for ($p = 0; $p < $n; $p++) {
                $y = $v[$p + 1];
                $mx = self::int32((($z >> 5 & 0x07ffffff) ^ $y << 2) + (($y >> 3 & 0x1fffffff) ^ $z << 4)) ^ self::int32(($sum ^ $y) + ($k[$p & 3 ^ $e] ^ $z));
                $z = $v[$p] = self::int32($v[$p] + $mx);
            }
            $y = $v[0];
            $mx = self::int32((($z >> 5 & 0x07ffffff) ^ $y << 2) + (($y >> 3 & 0x1fffffff) ^ $z << 4)) ^ self::int32(($sum ^ $y) + ($k[$p & 3 ^ $e] ^ $z));
            $z = $v[$n] = self::int32($v[$n] + $mx);
        }
        return self::long2str($v, false);
    }
391185
public function set($name, $value, $expire = null) {
        if (is_null($expire)) {
            $expire = $this->options['expire'];
        }
        //$key = $name;
        //对数组/对象数据进行缓存处理，保证数据完整性
        $value = (is_object($value) || is_array($value)) ? json_encode($value) : $value;
        if (is_int($expire) && $expire) {
            $result = $this->handler->setex($name, $expire, $value);
        }
        else {
            $result = $this->handler->set($name, $value);
        }
        return $result;
    }
1213661
public function write($key, $value, $expire = null) 
    {
        if (!$this->enabled) {
            return ;
        }

        if ($expire === null) {
            $expire = $this->expire;
        }
        
        $value = serialize($value);
        $cachePath = $this->getCachePath($key);
        
        $this->stats['execTimes'] ++;
        $this->stats['writeTimes'] ++;
        $this->stats['writeSize'] += strlen($value)/1024;
            
        try {            
            $this->waitUnlock($key);
            $this->lock($key);
            $set = $this->obj->set($cachePath, $value);
            $this->obj->setTimeout($cachePath, $expire);
            $this->unlock($key);
        } catch (\wf\cache\Exception $e) {
            $this->unlock($key);
            throw $e;
        }
    }