当前位置: 首页 > news >正文

Eureka 学习笔记1:服务端实例缓存

版本 awsVersion = ‘1.11.277’

缓存类型
registryConcurrentHashMap<String, Map<String, Lease<InstanceInfo>>>AbstractInstanceRegistry成员变量
readWriteCacheMapLoadingCacheResponseCacheImpl成员变量
readOnlyCacheMapConcurrentMap<Key, Value>ResponseCacheImpl成员变量

registry

// com.netflix.eureka.registry.AbstractInstanceRegistry
protected void postInit() {evictionTaskRef.set(new EvictionTask());evictionTimer.schedule(evictionTaskRef.get(),serverConfig.getEvictionIntervalTimerInMs(),// 配置evictionIntervalTimerInMsserverConfig.getEvictionIntervalTimerInMs());
}
class EvictionTask extends TimerTask {public void run() {long compensationTimeMs = getCompensationTimeMs();evict(compensationTimeMs);}// ...
}

evictionIntervalTimerInMs 指定清理未续约服务实例的时间间隔,默认 60s


readWriteCacheMap

// com.netflix.eureka.registry.ResponseCacheImpl
this.readWriteCacheMap =CacheBuilder.newBuilder()// 配置initialCapacityOfResponseCache.initialCapacity(serverConfig.getInitialCapacityOfResponseCache())// 配置responseCacheAutoExpirationInSeconds.expireAfterWrite(serverConfig.getResponseCacheAutoExpirationInSeconds(), TimeUnit.SECONDS)

initialCapacityOfResponseCache 指定 readWriteCacheMap 缓存容量大小,默认 1000

responseCacheAutoExpirationInSeconds 指定 readWriteCacheMap 缓存有效时间,默认 180s


readOnlyCacheMap

// com.netflix.eureka.registry.ResponseCacheImpl
// 配置shouldUseReadOnlyResponseCache
if (shouldUseReadOnlyResponseCache) {timer.schedule(getCacheUpdateTask(),new Date(((System.currentTimeMillis() / responseCacheUpdateIntervalMs) * responseCacheUpdateIntervalMs)+ responseCacheUpdateIntervalMs),// 配置responseCacheUpdateIntervalMsresponseCacheUpdateIntervalMs);
}private TimerTask getCacheUpdateTask() {return new TimerTask() {public void run() {// ...    for (Key key : readOnlyCacheMap.keySet()) {CurrentRequestVersion.set(key.getVersion());Value cacheValue = readWriteCacheMap.get(key);Value currentCacheValue = readOnlyCacheMap.get(key);if (cacheValue != currentCacheValue) {readOnlyCacheMap.put(key, cacheValue);}}}};
}

shouldUseReadOnlyResponseCache 指定是否使用 readOnlyCacheMap,默认 true

responseCacheUpdateIntervalMs 指定 readOnlyCacheMap 更新的时间间隔,默认 30s

http://www.lryc.cn/news/103142.html

相关文章:

  • vue : 无法加载文件 C:\Users\86182\AppData\Roaming\npm\vue.ps1,因为在此系统上禁止运行脚本。
  • FLinkCDC读取MySQl时间戳时区相关问题解决汇总
  • 第三篇-Tesla P40+CentOS7+CUDA 11.7 部署实践
  • AC+FIT(瘦AP)配置浅谈
  • 【Python】PySpark 数据计算 ② ( RDD#flatMap 方法 | RDD#flatMap 语法 | 代码示例 )
  • 二叉树题目:左叶子之和
  • Spark SQL报错: Task failed while writing rows.
  • Linux系统下U盘打不开: No application is registered as handling this file
  • 07 定时器处理非活动连接(上)
  • python——案例四:判断字符串中的元素组成
  • 一起学算法(插入排序篇)
  • JVM基础篇-本地方法栈与堆
  • 防雷保护区如何划分,防雷分区概念LPZ介绍
  • 随手笔记——3D−3D:ICP求解
  • Python调用各大机器翻译API大全
  • 重生之我要学C++第六天
  • SpringBoot中ErrorPage(错误页面)的使用--【ErrorPage组件】
  • 【Android】APP网络优化学习笔记
  • 简单的知识图谱可视化+绘制nx.Graph()时报错TypeError: ‘_AxesStack‘ object is not callable
  • 【Matlab】基于粒子群优化算法优化BP神经网络的时间序列预测(Excel可直接替换数据)
  • 【机器学习】Cost Function for Logistic Regression
  • 【EI/SCOPUS会议征稿】2023年第四届新能源与电气科技国际学术研讨会 (ISNEET 2023)
  • 【计算机网络】10、ethtool
  • 什么是前端工程化?
  • 【深度学习】【三维重建】windows11环境配置tiny-cuda-nn详细教程
  • Matlab 一种自适应搜索半径的特征提取方法
  • 基于opencv的几种图像滤波
  • puppeteer代理的搭建和配置
  • 【简单认识MySQL的MHA高可用配置】
  • 【云原生】一文学会Docker存储所有特性