ShortUrlRedisService.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Fanwe 方维直播系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class ShortUrlRedisService extends BaseRedisService
  10. {
  11. //记录私密直播邀请名单
  12. var $short_url_db;//:video_id hash数据key:user_id; value:1/0 [1:邀请;0:踢除]
  13. /**
  14. +----------------------------------------------------------
  15. * 架构函数
  16. +----------------------------------------------------------
  17. * @access public
  18. +----------------------------------------------------------
  19. */
  20. public function __construct()
  21. {
  22. parent::__construct($platform = 'sina');
  23. $this->short_url_db = $this->prefix.'short_url:'.$platform;
  24. }
  25. public function set_short($url_long,$url_short){
  26. $key = md5($url_long);
  27. //echo '1url_long:'.$url_long.';md5:'.$key.";url_short:".$url_short."<br>";
  28. $this->redis->hMSet($this->short_url_db,array($key=>$url_short));
  29. }
  30. public function get_short($url_long){
  31. $key = md5($url_long);
  32. $url_short = $this->redis->hGet($this->short_url_db,$key);
  33. //echo '2url_long:'.$url_long.';md5:'.$key.";url_short:".$url_short."<br>";
  34. return $url_short;
  35. }
  36. }//类定义结束
  37. ?>