hyperf-chat/app/Cache/ApplyNumCache.php

46 lines
817 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
namespace App\Cache;
/**
* Class ApplyNumCache
* @package App\Cache
*/
class ApplyNumCache
{
const KEY = 'friend:apply:unread:num';
/**
* 获取好友未读申请数
*
* @param int $user_id 用户ID
* @return string
*/
public static function get(int $user_id)
{
return redis()->hget(self::KEY, strval($user_id));
}
/**
* 设置未读好友申请数自增加1
*
* @param int $user_id 用户ID
* @return int
*/
public static function setInc(int $user_id)
{
return redis()->hincrby(self::KEY, $user_id, 1);
}
/**
* 删除好友申请未读数
*
* @param int $user_id
*/
public static function del(int $user_id)
{
redis()->hdel(self::KEY, $user_id);
}
}