<!--?php
/**
* 文件操作类
*/
class FileDir extends App
{
var $root = '';//文件根目录
var $node = '';//存储节点
/**
* 初始化,选择存储的节点
*
*/
function __construct()
{
parent::__construct();
$this->root = PUBLIC_ROOT.PUBLIC_ROOT_NODE;
if ( !is_dir($this->root) ){
$this->root = PUBLIC_ROOT.'node1';
$this->node = 'node1';
}else{
$this->node = PUBLIC_ROOT_NODE;
}
}
/**
* 目录hash算法
* @return string
*/
function dir_hash()
{
$val = array();
$md5 = md5(time());
for( $i = 0; $i <32 ; $i++){
$asc = ord(substr($md5,$i,1));
$len = strlen($asc)-1;
$val[] = substr($asc,$len,1);
}
$tmp = array();
for($i = 0; $i < 3 ; $i++){
$j = $i;
while( $j < 32 ){
@$tmp[$i] .= $val[$j];
$j = $j+5; }
}
$result = array();
foreach($tmp as $v){
$result[] = floatval($v) % 256 ;
}
return $result;
}
}
主要有以下几点:
1:通过配置,实现分布式存储。配置node为数组,然后根据算法从中选择要写入的节点,返回的信息中包含节点信息,节省了元数据的存储。不同节点可用不同的主机。用nfs实现多主机共享。
2:采用hash算法,生成三级hash目录,防止一个目录下的文件过多。–>
quick concept bond
porno How To Wear Animal Print Heels
This is where Goddiva’s Top 10 Fashion Websites enters the picture
how to lose weight fastHow to Make a Roomy Slingback Fit Better
how to lose weight fastHow to Make a Roomy Slingback Fit Better
