Files
whale-town-end/src/core/redis/redis.interface.ts
moyin de30649826 feat:添加Redis缓存服务
- 实现Redis服务接口和抽象层
- 提供真实Redis服务实现 (RealRedisService)
- 提供文件模拟Redis服务 (FileRedisService) 用于开发测试
- 支持基本的Redis操作:get、set、del、exists、ttl
- 添加Redis模块配置和依赖注入
2025-12-17 20:20:18 +08:00

53 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Redis接口定义
* 定义统一的Redis操作接口支持文件存储和真实Redis切换
*/
export interface IRedisService {
/**
* 设置键值对
* @param key 键
* @param value 值
* @param ttl 过期时间(秒)
*/
set(key: string, value: string, ttl?: number): Promise<void>;
/**
* 获取值
* @param key 键
* @returns 值或null
*/
get(key: string): Promise<string | null>;
/**
* 删除键
* @param key 键
* @returns 是否删除成功
*/
del(key: string): Promise<boolean>;
/**
* 检查键是否存在
* @param key 键
* @returns 是否存在
*/
exists(key: string): Promise<boolean>;
/**
* 设置过期时间
* @param key 键
* @param ttl 过期时间(秒)
*/
expire(key: string, ttl: number): Promise<void>;
/**
* 获取剩余过期时间
* @param key 键
* @returns 剩余时间(秒),-1表示永不过期-2表示不存在
*/
ttl(key: string): Promise<number>;
/**
* 清空所有数据
*/
flushall(): Promise<void>;
}