46 lines
1.0 KiB
Java
46 lines
1.0 KiB
Java
package com.guo.gateway.cache;
|
|
|
|
import com.guo.common.constant.CacheConstants;
|
|
import com.guo.gateway.cache.abs.CacheAbs;
|
|
import com.guo.gateway.model.NodeInfo;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
/**
|
|
* @author gxb
|
|
* @description 网关节点缓存
|
|
* @date 2024-04-18 11:43
|
|
*/
|
|
@Component
|
|
public class NodeCache extends CacheAbs<String> {
|
|
|
|
@Override
|
|
public String getPre() {
|
|
return CacheConstants.GATE_WAY_NODE_INFO;
|
|
}
|
|
|
|
/**
|
|
* 添加缓存数据
|
|
* @param nodeInfo 节点信息
|
|
*/
|
|
public void put(NodeInfo nodeInfo){
|
|
redisService.setCacheObject(encode(nodeInfo.getNodeId()),nodeInfo);
|
|
}
|
|
|
|
/**
|
|
* 获取缓存数据
|
|
* @param nodeId 节点ID
|
|
* @return 节点信息
|
|
*/
|
|
public NodeInfo get(String nodeId){
|
|
return redisService.getCacheObject(encode(nodeId));
|
|
}
|
|
|
|
/**
|
|
* 删除网关节点
|
|
* @param nodeId
|
|
*/
|
|
public void remove(String nodeId){
|
|
redisService.deleteObject(encode(nodeId));
|
|
}
|
|
}
|