Storage.class.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. * 操作句柄
  17. * @var string
  18. * @access protected
  19. */
  20. protected static $handler;
  21. /**
  22. * 连接分布式文件系统
  23. * @access public
  24. * @param string $type 文件类型
  25. * @param array $options 配置数组
  26. * @return void
  27. */
  28. public static function connect($type = 'File', $options = array())
  29. {
  30. $class = 'Think\\Storage\\Driver\\' . ucwords($type);
  31. self::$handler = new $class($options);
  32. }
  33. public static function __callStatic($method, $args)
  34. {
  35. //调用缓存驱动的方法
  36. if (method_exists(self::$handler, $method)) {
  37. return call_user_func_array(array(self::$handler, $method), $args);
  38. }
  39. }
  40. }