Storage.class.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | TOPThink [ WE CAN DO IT JUST THINK ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013 http://topthink.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: liu21st <liu21st@gmail.com>
  10. // +----------------------------------------------------------------------
  11. namespace Think;
  12. // 分布式文件存储类
  13. class Storage {
  14. /**
  15. * 操作句柄
  16. * @var string
  17. * @access protected
  18. */
  19. static protected $handler ;
  20. /**
  21. * 连接分布式文件系统
  22. * @access public
  23. * @param string $type 文件类型
  24. * @param array $options 配置数组
  25. * @return void
  26. */
  27. static public function connect($type='File',$options=array()) {
  28. $class = 'Think\\Storage\\Driver\\'.ucwords($type);
  29. self::$handler = new $class($options);
  30. }
  31. static public function __callstatic($method,$args){
  32. //调用缓存驱动的方法
  33. if(method_exists(self::$handler, $method)){
  34. return call_user_func_array(array(self::$handler,$method), $args);
  35. }
  36. }
  37. }