123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- /**
- * Created by PhpStorm.
- * User : zgcLives
- * CreateTime : 2022/10/20 11:57
- */
- namespace addons\exam\library;
- /**
- * 缓存服务
- */
- class CacheService
- {
- /**
- * 缓存Key:微信用户sessionKey
- * @param $user_id
- * @return string
- */
- public static function cacheKeyWechatUserSessionKey($user_id)
- {
- return "exam:wechat_user:session_key-{$user_id}";
- }
- /**
- * 设置微信用户sessionKey缓存
- * @param $user_id
- * @param $session_key
- * @return void
- */
- public static function setWechatUserSessionKey($user_id, $session_key)
- {
- $cache_key = self::cacheKeyWechatUserSessionKey($user_id);
- cache($cache_key, $session_key);
- }
- /**
- * 获取微信用户sessionKey缓存
- * @param $user_id
- * @return string
- */
- public static function getWechatUserSessionKey($user_id)
- {
- $cache_key = self::cacheKeyWechatUserSessionKey($user_id);
- return cache($cache_key);
- }
-
- }
|