parent
724ceb5109
commit
ada54b6b97
@ -0,0 +1,44 @@
|
||||
package org.opsli.common.enums;
|
||||
|
||||
/**
|
||||
* 数据库类型
|
||||
*
|
||||
* @author Parker
|
||||
*/
|
||||
public enum CacheType {
|
||||
|
||||
/** 缓存类型 */
|
||||
TIMED("timed", "时控数据"),
|
||||
EDEN("eden", "永久数据"),
|
||||
EDEN_HASH("edenhash", "永久Hash数据")
|
||||
|
||||
;
|
||||
|
||||
private final String name;
|
||||
private final String desc;
|
||||
|
||||
public static CacheType getCacheType(String cacheType) {
|
||||
CacheType[] var1 = values();
|
||||
for (CacheType type : var1) {
|
||||
if (type.name.equalsIgnoreCase(cacheType)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return this.desc;
|
||||
}
|
||||
|
||||
// =================
|
||||
|
||||
CacheType(final String name, final String desc) {
|
||||
this.name = name;
|
||||
this.desc = desc;
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.opsli.core.autoconfigure.properties;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 接口路径前缀配置
|
||||
* @author parker
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = CacheProperties.PROP_PREFIX)
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class CacheProperties {
|
||||
|
||||
public static final String PROP_PREFIX = "spring.cache-conf";
|
||||
|
||||
/** 缓存前缀 */
|
||||
private String prefix;
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,67 +0,0 @@
|
||||
/**
|
||||
* Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.opsli.core.cache.pushsub.handler;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.opsli.common.constants.CacheConstants;
|
||||
import org.opsli.common.constants.DictConstants;
|
||||
import org.opsli.core.cache.local.CacheUtil;
|
||||
import org.opsli.core.cache.pushsub.enums.CacheType;
|
||||
import org.opsli.core.cache.pushsub.enums.MsgArgsType;
|
||||
import org.opsli.core.cache.pushsub.enums.PushSubType;
|
||||
import org.opsli.plugins.cache.EhCachePlugin;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @BelongsPackage: org.opsli.core.cache.pushsub.handler
|
||||
* @Author: Parker
|
||||
* @CreateTime: 2020-09-15 16:24
|
||||
* @Description: 永久数据处理
|
||||
*/
|
||||
@Slf4j
|
||||
public class EdenDataHandler implements RedisPushSubHandler{
|
||||
|
||||
@Autowired
|
||||
private EhCachePlugin ehCachePlugin;
|
||||
|
||||
@Override
|
||||
public PushSubType getType() {
|
||||
return PushSubType.EDEN_DATA;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handler(JSONObject msgJson) {
|
||||
String key = (String) msgJson.get(MsgArgsType.CACHE_DATA_KEY.toString());
|
||||
Object value = msgJson.get(MsgArgsType.CACHE_DATA_VALUE.toString());
|
||||
CacheType type = CacheType.valueOf((String )msgJson.get(MsgArgsType.CACHE_DATA_TYPE.toString()));
|
||||
|
||||
// 解析 key
|
||||
String handleKey = CacheUtil.handleKey(CacheConstants.EDEN_DATA,key);
|
||||
|
||||
// 缓存更新
|
||||
if(CacheType.UPDATE == type){
|
||||
ehCachePlugin.put(CacheConstants.HOT_DATA, handleKey, value);
|
||||
}
|
||||
// 缓存删除
|
||||
else if(CacheType.DELETE == type){
|
||||
ehCachePlugin.delete(CacheConstants.HOT_DATA, handleKey);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue