2026-06-24 f4bd1f3c89d906131495a0aca5aaf82966378510
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package cn.iocoder.yudao.module.iot.dal.redis;
 
import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDevicePropertyDO;
 
/**
 * IoT Redis Key 枚举类
 *
 * @author 芋道源码
 */
public interface RedisKeyConstants {
 
    /**
     * 设备属性的数据缓存,采用 HASH 结构
     * <p>
     * KEY 格式:device_property:{deviceId}
     * HASH KEY:identifier 属性标识
     * VALUE 数据类型:String(JSON) {@link IotDevicePropertyDO}
     */
    String DEVICE_PROPERTY = "iot:device_property:%d";
 
    /**
     * 设备的最后上报时间,采用 ZSET 结构
     *
     * KEY 格式:{deviceId}
     * SCORE:上报时间
     */
    String DEVICE_REPORT_TIMES = "iot:device_report_times";
 
    /**
     * 设备关联的网关 serverId 缓存,采用 HASH 结构
     *
     * KEY 格式:device_server_id
     * HASH KEY:{deviceId}
     * VALUE 数据类型:String serverId
     */
    String DEVICE_SERVER_ID = "iot:device_server_id";
 
    /**
     * 设备信息的数据缓存,使用 Spring Cache 操作(忽略租户)
     *
     * KEY 格式 1:device_${deviceId}
     * KEY 格式 2:device_${productKey}_${deviceName}
     * VALUE 数据类型:String(JSON)
     */
    String DEVICE = "iot:device";
 
    /**
     * 产品信息的数据缓存,使用 Spring Cache 操作(忽略租户)
     *
     * KEY 格式:product_${productId}
     * VALUE 数据类型:String(JSON)
     */
    String PRODUCT = "iot:product";
 
    /**
     * 物模型的数据缓存,使用 Spring Cache 操作(忽略租户)
     *
     * KEY 格式:thing_model_${productId}
     * VALUE 数据类型:String 数组(JSON),即 {@link cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotThingModelDO} 列表
     */
    String THING_MODEL_LIST = "iot:thing_model_list";
 
    /**
     * 数据流转规则的数据缓存,使用 Spring Cache 操作
     *
     * KEY 格式:data_rule_list_${deviceId}_${method}_${identifier}
     * VALUE 数据类型:String 数组(JSON),即 {@link cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotDataRuleDO} 列表
     */
    String DATA_RULE_LIST = "iot:data_rule_list";
 
    /**
     * 数据目的的数据缓存,使用 Spring Cache 操作
     *
     * KEY 格式:data_sink_${id}
     * VALUE 数据类型:String(JSON),即 {@link cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotDataSinkDO}
     */
    String DATA_SINK = "iot:data_sink";
 
    /**
     * 场景联动规则的数据缓存,使用 Spring Cache 操作
     * <p>
     * KEY 格式:scene_rule_list_${productId}_${deviceId}
     * VALUE 数据类型:String 数组(JSON),即 {@link cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotSceneRuleDO} 列表
     */
    String SCENE_RULE_LIST = "iot:scene_rule_list";
 
    /**
     * WebSocket 连接分布式锁
     * <p>
     * KEY 格式:websocket_connect_lock:${serverUrl}
     * 用于保证 WebSocket 重连操作的线程安全
     */
    String WEBSOCKET_CONNECT_LOCK = "iot:websocket_connect_lock:%s";
 
}