| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 | 
							- <?php
 
- /**
 
-  * HeartTimeCache.php  UTF-8
 
-  * 心跳时间缓存
 
-  *
 
-  * @date    : 2019/11/30 15:12
 
-  *
 
-  * @license 这不是一个自由软件,未经授权不许任何使用和传播。
 
-  * @author  : chenbingling <cbl@huosdk.com>
 
-  * @version : HUOSDK 8.5
 
-  */
 
- namespace huoIdentify\controller;
 
- use huo\controller\common\Base;
 
- use huolib\constant\CacheConst;
 
- use huolib\constant\CommonConst;
 
- use think\Cache;
 
- class HeartTimeCache extends Base {
 
-     protected $cache_key_prefix = CacheConst::CACHE_LAST_HEART_TIME_PREFIX;  //缓存前缀
 
-     public static function ins() {
 
-         return new static();
 
-     }
 
-     /***
 
-      * 获取缓存前缀
 
-      *
 
-      * @param int    $app_id    游戏id
 
-      * @param int    $mem_id    玩家id
 
-      * @param string $device_id 设备ID android 为imei ios 为idfa h5 为 永久cookie标识 huoh5开头标识
 
-      *
 
-      * @return string
 
-      */
 
-     public function getCacheKeyByAppMemDevice($app_id, $mem_id, $device_id) {
 
-         return $this->cache_key_prefix.'app_'.$app_id.'_mem_'.$mem_id.'_device_'.$device_id;
 
-     }
 
-     /**
 
-      * 获取最后一次心跳时间
 
-      *
 
-      * @param int    $app_id    游戏id
 
-      * @param int    $mem_id    玩家id
 
-      * @param string $device_id 设备ID android 为imei ios 为idfa h5 为 永久cookie标识 huoh5开头标识
 
-      *
 
-      * @return int|mixed
 
-      */
 
-     public function getLastHeartTime($app_id, $mem_id, $device_id) {
 
-         $_cache_key = $this->getCacheKeyByAppMemDevice($app_id, $mem_id, $device_id);
 
-         $_time = Cache::get($_cache_key);
 
-         if (empty($_time)) {
 
-             return CommonConst::CONST_ZERO;
 
-         }
 
-         return $_time;
 
-     }
 
-     /**
 
-      * 设置最后一次心跳时间
 
-      *
 
-      * @param int    $time
 
-      * @param int    $app_id    游戏id
 
-      * @param int    $mem_id    玩家id
 
-      * @param string $device_id 设备ID android 为imei ios 为idfa h5 为 永久cookie标识 huoh5开头标识
 
-      */
 
-     public function setLastHeartTime($time, $app_id, $mem_id, $device_id) {
 
-         $_cache_key = $this->getCacheKeyByAppMemDevice($app_id, $mem_id, $device_id);
 
-         Cache::set($_cache_key, $time);
 
-     }
 
- }
 
 
  |