CN111752902A - 动态热数据缓存方法 - Google Patents

动态热数据缓存方法 Download PDF

Info

Publication number
CN111752902A
CN111752902A CN202010505053.4A CN202010505053A CN111752902A CN 111752902 A CN111752902 A CN 111752902A CN 202010505053 A CN202010505053 A CN 202010505053A CN 111752902 A CN111752902 A CN 111752902A
Authority
CN
China
Prior art keywords
cache
weight
access
parameter
access parameter
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010505053.4A
Other languages
English (en)
Inventor
黄圣超
吉鸿呈
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jiangsu Task Network Technology Co ltd
Original Assignee
Jiangsu Task Network Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jiangsu Task Network Technology Co ltd filed Critical Jiangsu Task Network Technology Co ltd
Priority to CN202010505053.4A priority Critical patent/CN111752902A/zh
Publication of CN111752902A publication Critical patent/CN111752902A/zh
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2255Hash tables
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/172Caching, prefetching or hoarding of files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/1805Append-only file systems, e.g. using logs or journals to store data
    • G06F16/1815Journaling file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computational Linguistics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

本发明公开了动态热数据缓存方法,通过访问参数的权重与预先设定访问参数的权重即通过缓存命中率的权重、访问频率的权重与预设权重对比,调整缓存的各时间戳,结合历史缓存参数设置缓存参数。本发明能够自动识别热数据并进行自动缓存,通过热数据预判能够极大减缓服务器压力;缓存过期时间不再是固定不变的,而是动态的不断优化的,能够避免出现脏数据,不断调整缓存生命周期,寻找最优缓存生命周期。

Description

动态热数据缓存方法
技术领域
本发明涉及数据处理技术领域,尤其涉及动态热数据缓存方法。
背景技术
在web场景中,为了应对高并发,减少服务器压力,需要去对热数据做缓存,即为将需要频繁读取的数据的存储形式从文件、数据库等改为内存存储,因此存在如membercache、redis这类的内存数据库,减少I/O消耗。
传统技术方案为:开发者判断哪些是热数据,通过将热数据写到业务代码方式做缓存,同时还需要监听数据库数据更新,以便更新缓存,防止脏数据;利用如nginx服务器去做动态缓存;利用redis数据库的淘汰策略优化存储热数据。
传统技术方案存在以下缺点:需要依赖开发者人工去识别热数据,将缓存代码结合到业务代码中;缓存时间是固定的,未到缓存时间不会去更新,且只适用于静态数据;redis数据库作为数据库,只能对已存储的数据优化,且过期时间设定机械。
发明内容
本发明的目的就在于为了解决上述问题而提供动态热数据缓存方法,包括如下步骤:
S1:读取访问请求,获取访问参数;
S2:判断是否存在缓存,若存在缓存则记录访问参数,转S3,否则若无缓存则转S4;
S3:检测缓存是否有效,若缓存有效则转S7,否则若缓存无效则删除缓存,转S4;
S4:预先设定访问参数的权重;
S5:记录访问参数,更新缓存日志数据;
S6:计算访问参数的权重,将当前访问参数的权重与预先设定的访问参数的权重对比,若当前访问参数的权重大于预先设定的访问参数的权重,则建立缓存,设置缓存参数转S7;否则转S7;
S7:返回响应。
本发明的有益效果在于:本发明能够自动识别热数据并进行自动缓存,通过热数据预判能够极大减缓服务器压力;缓存过期时间不再是固定不变的,而是动态的不断优化的,能够避免出现脏数据,能够不断调整缓存参数,寻找最优缓存生命周期。
附图说明
图1是本发明的流程图。
具体实施方式
下面结合附图对本发明作进一步说明:
如附图1所示,本发明动态热数据缓存方法,包括如下步骤:
S1:读取访问请求,获取访问参数;
S2:判断是否存在缓存,若存在缓存则记录访问参数,转S3,否则若无缓存则转S4;
S3:检测缓存是否有效,若缓存有效则转S7,否则若缓存无效则删除缓存,转S4;
S4:预先设定访问参数的权重;
S5:记录访问参数,更新缓存日志数据;
S6:计算访问参数的权重,将当前访问参数的权重与预先设定的访问参数的权重对比,若当前访问参数的权重大于预先设定的访问参数的权重,则建立缓存,设置缓存参数转S7;否则转S7;
S7:返回响应。
具体的,所述访问参数包括始时间戳、访问次数、响应的哈希值、缓存命中次数、缓存命中率、访问频率、最后缓存不命中时间戳与缓存生命周期。
具体的,所述S3中检测缓存是否有效是对比缓存日志数据中的哈希值与响应的哈希值,若相同则缓存有效,否则缓存无效。
具体的,所述S2中访问参数的权重至少包括缓存命中率的权重与访问频率的权重。
具体的,所述S3中检测缓存有效性为随机检测。
具体的,所述缓存参数包括始时间戳、缓存过期时间、缓存生命周期与最后缓存不命中时间戳。
具体的,设置缓存参数的具体过程为设置缓存参数取历史数据的中数。
从接口访问开始,解析并记录访问参数,访问参数包括起始时间戳、访问次数、响应的哈希值、缓存命中次数、最后缓存不命中时间戳与缓存生命周期。
判断是否存在缓存,在有缓存时,记录访问参数,随机检测缓存的有效性,计算提取缓存日志数据中的哈希值与响应的哈希值,并进行对比,若相同则缓存有效,否则缓存无效,若缓存有效则使用缓存,返回响应,若缓存无效则删除缓存;若无缓存或者缓存无效,则提取缓存命中次数、访问次数与时间窗口,根据缓存命中次数与访问次数之比计算缓存命中率,根据访问次数与时间窗口之比计算访问频率,访问频率用于分辨热数据。预先设定缓存命中率与访问频率的权重,并以缓存命中率权重作为优先权重;记录访问参数,并更新到缓存日志数据中;缓存设置参数包括始时间戳、缓存过期时间、缓存生命周期与最后缓存不命中时间戳;通过访问参数计算当前缓存命中率的权重与访问频率的权重,并将其与预设的缓存命中率权重与访问频率的权重比对,若超过预设缓存命中率权重与访问频率的权重则建立缓存,设置缓存参数即调整时间戳、缓存过期时间、缓存生命周期与最后缓存不命中时间戳,取历史数据的中数;更新缓存日志数据,返回响应。
结合历史访问参数,调整预先设定的访问参数的权重,通过访问参数的权重与预先设定访问参数的权重即通过缓存命中率的权重、访问频率的权重与预设权重对比,调整缓存的各时间戳,结合历史缓存参数设置缓存参数,达到提高缓存命中率、优化缓存的目的,实现全过程闭环反馈。
本发明能够通过日志中的访问次数和时间窗口参数调整访问频率权重,分析现有热数据参数,抽取热数据参数特征,对请求高并发时间段和数量以及请求接口进行数据预处理,在高并发来临前调整缓存参数;缓存生命周期使用历史数据中数,随着生命周期参数的不断增多,不断调整缓存过期时间,有利于寻找最优缓存生命周期。
本发明能够自动识别热数据并进行自动缓存,通过热数据预判能够极大减缓服务器压力;缓存过期时间不再是固定不变的,而是动态的不断优化的,能够避免出现脏数据,能够不断调整缓存参数,寻找最优缓存生命周期。
本发明的技术方案不限于上述具体实施例的限制,凡是根据本发明的技术方案做出的技术变形,均落入本发明的保护范围之内。

Claims (7)

1.动态热数据缓存方法,其特征在于,包括如下步骤:
S1:读取访问请求,获取访问参数;
S2:判断是否存在缓存,若存在缓存则记录访问参数,转S3,否则,转S4;
S3:检测缓存是否有效,若缓存有效则转S7,否则若缓存无效则删除缓存,转S4;
S4:预先设定访问参数的权重;
S5:记录访问参数,更新缓存日志数据;
S6:计算访问参数的权重,将当前访问参数的权重与预先设定的访问参数的权重对比,若当前访问参数的权重大于预先设定的访问参数的权重,则建立缓存,设置缓存参数转S7;否则转S7;
S7:返回响应。
2.根据权利要求1所述动态热数据缓存方法,其特征在于,所述访问参数包括始时间戳、访问次数、响应的哈希值、缓存命中次数、缓存命中率、访问频率、最后缓存不命中时间戳与缓存生命周期。
3.根据权利要求1所述动态热数据缓存方法,其特征在于,所述S3中检测缓存是否有效是对比缓存日志数据中的哈希值与响应的哈希值,若相同则缓存有效,否则缓存无效。
4.根据权利要求1所述动态热数据缓存方法,其特征在于,所述S2中访问参数的权重至少包括缓存命中率的权重与访问频率的权重。
5.根据权利要求1所述动态热数据缓存方法,其特征在于,所述S3中检测缓存有效性为随机检测。
6.根据权利要求1所述动态热数据缓存方法,其特征在于,所述缓存参数包括始时间戳、缓存过期时间、缓存生命周期与最后缓存不命中时间戳。
7.根据权利要求1所述动态热数据缓存方法,其特征在于,设置缓存参数的具体过程为缓存设置参数取历史数据的中数。
CN202010505053.4A 2020-06-05 2020-06-05 动态热数据缓存方法 Pending CN111752902A (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010505053.4A CN111752902A (zh) 2020-06-05 2020-06-05 动态热数据缓存方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010505053.4A CN111752902A (zh) 2020-06-05 2020-06-05 动态热数据缓存方法

Publications (1)

Publication Number Publication Date
CN111752902A true CN111752902A (zh) 2020-10-09

Family

ID=72676141

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010505053.4A Pending CN111752902A (zh) 2020-06-05 2020-06-05 动态热数据缓存方法

Country Status (1)

Country Link
CN (1) CN111752902A (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111753329A (zh) * 2020-06-05 2020-10-09 江苏任务网络科技有限公司 一种锁定用户远程登录的自动化预警方法

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102511043A (zh) * 2011-11-26 2012-06-20 华为技术有限公司 缓存文件替换方法、装置及系统
CN105306457A (zh) * 2015-09-30 2016-02-03 努比亚技术有限公司 数据缓存装置及方法
CN108459821A (zh) * 2017-02-21 2018-08-28 中兴通讯股份有限公司 一种数据缓存的方法及装置
CN108920573A (zh) * 2018-06-22 2018-11-30 北京奇艺世纪科技有限公司 一种数据缓存处理方法、装置及终端设备

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102511043A (zh) * 2011-11-26 2012-06-20 华为技术有限公司 缓存文件替换方法、装置及系统
CN105306457A (zh) * 2015-09-30 2016-02-03 努比亚技术有限公司 数据缓存装置及方法
CN108459821A (zh) * 2017-02-21 2018-08-28 中兴通讯股份有限公司 一种数据缓存的方法及装置
CN108920573A (zh) * 2018-06-22 2018-11-30 北京奇艺世纪科技有限公司 一种数据缓存处理方法、装置及终端设备

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111753329A (zh) * 2020-06-05 2020-10-09 江苏任务网络科技有限公司 一种锁定用户远程登录的自动化预警方法

Similar Documents

Publication Publication Date Title
Canim et al. SSD bufferpool extensions for database systems
US7120759B2 (en) Storage system and method for prestaging data in a cache for improved performance
US7343396B2 (en) Precomputation of web documents
CN104156323B (zh) 一种高速缓冲存储器的数据块长度自适应读取方法及装置
KR100745883B1 (ko) 투명한 네트워크 에지의 데이터 캐시
US20020087802A1 (en) System and method for maintaining prefetch stride continuity through the use of prefetch bits
US6480939B2 (en) Method and apparatus for filtering prefetches to provide high prefetch accuracy using less hardware
EP3388935B1 (en) Cache management method, cache controller and computer system
CN105335102A (zh) 一种缓存数据处理方法及装置
CN104216838A (zh) 双缓存数据处理方法及系统
CN111858405B (zh) 一种分布式存储的数据缓存方法和装置
US20050240567A1 (en) Avoiding creation of database statistics
CN111752902A (zh) 动态热数据缓存方法
US8250302B2 (en) Cache management using sampled values assigned to a request
CN106407398A (zh) 一种数据存储方法及系统
CN111913913B (zh) 访问请求的处理方法和装置
CN111752905A (zh) 一种基于对象存储的大文件分布式缓存系统
US7237084B2 (en) Method and program product for avoiding cache congestion by offsetting addresses while allocating memory
CN110471914B (zh) 一种实时数据处理中维度关联的方法及系统
US20220222257A1 (en) Video data storage method, apparatus, terminal device and storage medium
JPH08263380A (ja) ディスクキャッシュ制御方式
CN114461590A (zh) 一种基于关联规则的数据库文件页预取方法及装置
CN109582233A (zh) 一种数据的缓存方法和装置
CN114328522A (zh) 一种基于布隆过滤器的图书判别方式在数字图书馆中的应用方法
CN117270778A (zh) 一种存储系统的缓存方法、装置及设备

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination