Data caching method, device, terminal and computer readable storage medium

文档序号:1686964 发布日期:2020-01-03 浏览:22次 中文

阅读说明:本技术 数据缓存方法、装置、终端以及计算机可读存储介质 (Data caching method, device, terminal and computer readable storage medium ) 是由 陈溯 于 2018-06-27 设计创作,主要内容包括:本发明实施例提供一种数据缓存方法、装置、终端以及计算机可读存储介质,方法包括:在多个线程运行时,获取每个线程中待缓存数据的数据类型;根据数据类型在预设的多个缓存块中确定与数据类型相对应的至少一个目标缓存块;根据目标缓存块确定与目标缓存块相对应的加密方式;利用加密方式将待缓存数据存储至目标缓存块。本发明实现了当存在多个线程运行时,根据数据类型在预设的多个缓存块中确定与数据类型相对应的至少一个目标缓存块,并利用加密方式将待缓存数据存储至目标缓存块,从而实现了当存在多个线程的待缓存数据时,可以分别存储至相对应的目标缓存块中,有效地缩短了每个线程的无效等待时间,保证了每个线程的运行速率。(The embodiment of the invention provides a data caching method, a data caching device, a terminal and a computer readable storage medium, wherein the method comprises the following steps: when a plurality of threads run, acquiring the data type of data to be cached in each thread; determining at least one target cache block corresponding to the data type in a plurality of preset cache blocks according to the data type; determining an encryption mode corresponding to the target cache block according to the target cache block; and storing the data to be cached to the target cache block by utilizing an encryption mode. The invention realizes that at least one target cache block corresponding to the data type is determined in the preset cache blocks according to the data type when a plurality of threads run, and the data to be cached is stored in the target cache block by using an encryption mode, thereby realizing that the data to be cached of the threads can be respectively stored in the corresponding target cache block when the data to be cached of the threads exist, effectively shortening the invalid waiting time of each thread and ensuring the running speed of each thread.)

1. A method for caching data, comprising:

when a plurality of threads run, acquiring the data type of data to be cached in each thread;

determining at least one target cache block corresponding to the data type in a plurality of preset cache blocks according to the data type;

determining an encryption mode corresponding to the target cache block according to the target cache block;

and storing the data to be cached to the target cache block by utilizing the encryption mode.

2. The method according to claim 1, wherein after storing the data to be cached in the target cache block by using the encryption method, the method further comprises:

determining a cleaning mode corresponding to the target cache block according to the target cache block;

acquiring the failure time of the data to be cached;

and cleaning the data to be cached according to the failure time by utilizing the cleaning mode.

3. The method of claim 2, wherein obtaining the expiration time of the data to be cached comprises:

acquiring the storage time of the data to be cached stored to the target cache block and the preset valid time of the data to be cached;

and determining the failure time according to the storage time and the effective time.

4. The method of claim 2, further comprising:

acquiring a preset updating access interface for accessing the target cache block;

and updating the invalidation time of the data to be cached in the target cache block by using the updating access interface.

5. The method according to any one of claims 1-4, further comprising:

acquiring a preset management interface for managing the target cache block;

and managing the target cache block by utilizing the management interface.

6. The method of claim 5,

the management interface includes at least one of:

the system comprises a configuration management interface used for reading and configuring the cache information in the target cache block, an expansion management interface used for expanding the cache information in the target cache block, and a service management interface used for being in communication connection with a user.

7. A data caching apparatus, comprising:

the obtaining module is used for obtaining the data type of the data to be cached in each thread when the plurality of threads run;

the determining module is used for determining at least one target cache block corresponding to the data type in a plurality of preset cache blocks according to the data type;

the determining module is further configured to determine, according to the target cache block, an encryption manner corresponding to the target cache block;

and the storage module is used for storing the data to be cached to the target cache block by utilizing the encryption mode.

8. The apparatus of claim 7,

the determining module is further configured to determine, according to the target cache block, a cleaning manner corresponding to the target cache block after the data to be cached is stored in the target cache block by using the encryption manner;

the obtaining module is further configured to obtain expiration time of the data to be cached;

the device further comprises:

and the cleaning module is used for cleaning the data to be cached according to the failure time and by utilizing the cleaning mode.

9. The apparatus of claim 8, wherein the obtaining module is configured to:

acquiring the storage time of the data to be cached stored to the target cache block and the preset valid time of the data to be cached;

and determining the failure time according to the storage time and the effective time.

10. The apparatus of claim 8,

the obtaining module is further configured to obtain a preset update access interface for accessing the target cache block;

the device further comprises:

and the updating module is used for updating the invalidation time of the data to be cached in the target cache block by using the updating access interface.

11. The apparatus according to any one of claims 7 to 10,

the obtaining module is further configured to obtain a preset management interface for managing the target cache block;

the device further comprises:

and the management module is used for managing the target cache block by utilizing the management interface.

12. The apparatus of claim 11,

the management interface includes at least one of:

the system comprises a configuration management interface used for reading and configuring the cache information in the target cache block, an expansion management interface used for expanding the cache information in the target cache block, and a service management interface used for being in communication connection with a user.

13. A data caching terminal, comprising:

a memory;

a processor; and

a computer program;

wherein the computer program is stored in the memory and configured to be executed by the processor to implement a data caching method as claimed in any one of claims 1 to 6.

14. A computer-readable storage medium, having stored thereon a computer program;

the computer program is executed by a processor to implement a data caching method as claimed in any one of claims 1 to 6.

Technical Field

The present invention relates to the field of data processing technologies, and in particular, to a data caching method, an apparatus, a terminal, and a computer-readable storage medium.

Background

At present, terminal application updating modes comprise a hot updating mode and a cold deploying mode, wherein the hot updating mode is a common updating mode for a plurality of application programs APP, in brief, after a user downloads an App through an App Store, the user opens the App to meet the instant updating mode, and only the code of an updating part needs to be downloaded and installed during updating; the cold deployment means that the APP is updated in the AppStore, and all installation packages need to be downloaded again during updating; compared with cold deployment, hot update has the advantages of high update speed, data loss prevention and the like.

When an application program is updated by means of hot update, a plurality of threads may run simultaneously, and at this time, in order to meet the hot update requirement and ensure data consistency under the condition of multithreading, all data is generally stored in one cache block, and each time the cache block is accessed, the cache block needs to be locked.

However, as the amount of cache data increases, the amount of storage data in the cache block increases, and in order to ensure stable reliability of the data in the cache block, the granularity of the lock of the cache block becomes very large, and at this time, the invalid waiting time of each thread becomes very long, so that the running speed of the thread is reduced, and good experience of a user is affected.

Disclosure of Invention

Embodiments of the present invention provide a data caching method, an apparatus, a terminal, and a computer-readable storage medium, so as to solve the problem that in the prior art, the invalid waiting time of each thread becomes very long, thereby reducing the running speed of the thread and affecting the good experience of a user.

A first aspect of the embodiments of the present invention provides a data caching method, including:

when a plurality of threads run, acquiring the data type of data to be cached in each thread;

determining at least one target cache block corresponding to the data type in a plurality of preset cache blocks according to the data type;

determining an encryption mode corresponding to the target cache block according to the target cache block;

and storing the data to be cached to the target cache block by utilizing the encryption mode.

As described above, after storing the data to be cached in the target cache block by using the encryption method, the method further includes:

determining a cleaning mode corresponding to the target cache block according to the target cache block;

acquiring the failure time of the data to be cached;

and cleaning the data to be cached according to the failure time by utilizing the cleaning mode.

The method for acquiring the expiration time of the data to be cached comprises the following steps:

acquiring the storage time of the data to be cached stored to the target cache block and the preset valid time of the data to be cached;

and determining the failure time according to the storage time and the effective time.

The method as described above, further comprising:

acquiring a preset updating access interface for accessing the target cache block;

and updating the invalidation time of the data to be cached in the target cache block by using the updating access interface.

The method as described above, further comprising:

acquiring a preset management interface for managing the target cache block;

and managing the target cache block by utilizing the management interface.

The method as described above, the management interface comprising at least one of:

the system comprises a configuration management interface used for reading and configuring the cache information in the target cache block, an expansion management interface used for expanding the cache information in the target cache block, and a service management interface used for being in communication connection with a user.

A second aspect of the present invention provides a data caching apparatus, including:

the obtaining module is used for obtaining the data type of the data to be cached in each thread when the plurality of threads run;

the determining module is used for determining at least one target cache block corresponding to the data type in a plurality of preset cache blocks according to the data type;

the determining module is further configured to determine, according to the target cache block, an encryption manner corresponding to the target cache block;

and the storage module is used for storing the data to be cached to the target cache block by utilizing the encryption mode.

The apparatus as described above, the determining module is further configured to determine, according to the target cache block, a cleaning manner corresponding to the target cache block after the data to be cached is stored in the target cache block by using the encryption manner;

the obtaining module is further configured to obtain expiration time of the data to be cached;

the device further comprises:

and the cleaning module is used for cleaning the data to be cached according to the failure time and by utilizing the cleaning mode.

The apparatus as described above, the obtaining module configured to:

acquiring the storage time of the data to be cached stored to the target cache block and the preset valid time of the data to be cached;

and determining the failure time according to the storage time and the effective time.

The apparatus as described above, the obtaining module is further configured to obtain a preset update access interface for accessing the target cache block;

the device further comprises:

and the updating module is used for updating the invalidation time of the data to be cached in the target cache block by using the updating access interface.

The apparatus as described above, the obtaining module is further configured to obtain a preset management interface for managing the target cache block;

the device further comprises:

and the management module is used for managing the target cache block by utilizing the management interface.

The apparatus as described above, the management interface comprising at least one of:

the system comprises a configuration management interface used for reading and configuring the cache information in the target cache block, an expansion management interface used for expanding the cache information in the target cache block, and a service management interface used for being in communication connection with a user.

A third aspect of the embodiments of the present invention provides a data caching terminal, including:

a memory;

a processor; and

a computer program;

wherein the computer program is stored in the memory and configured to be executed by the processor to implement a data caching method as described in the first aspect above.

A fourth aspect of embodiments of the present invention provides a computer-readable storage medium having a computer program stored thereon;

the computer program is executed by a processor to implement a data caching method as described in the first aspect above.

According to the data caching method, the data caching device, the data caching terminal and the computer readable storage medium, when a plurality of threads run, at least one target cache block corresponding to the data type is determined in a plurality of preset cache blocks according to the data type, and the data to be cached is stored in the target cache block in an encryption mode, so that the data to be cached of the threads can be respectively stored in the corresponding target cache block when the data to be cached of the threads exist, the invalid waiting time of each thread is effectively shortened, the running speed of each thread is guaranteed, good experience of a user is improved, and popularization and application of markets are facilitated.

Drawings

Fig. 1 is a schematic flowchart of a data caching method according to an embodiment of the present invention;

fig. 2 is a schematic flowchart of another data caching method according to an embodiment of the present invention;

fig. 3 is a schematic flowchart of a process of obtaining the expiration time of the data to be cached according to an embodiment of the present invention;

fig. 4 is a schematic flowchart of another data caching method according to an embodiment of the present invention;

fig. 5 is a schematic flowchart of another data caching method according to an embodiment of the present invention;

FIG. 6 is a diagram illustrating a plurality of cache blocks according to an embodiment of the present invention;

fig. 7 is a schematic structural diagram of a data caching apparatus according to an embodiment of the present invention;

fig. 8 is a schematic structural diagram of a data caching terminal according to an embodiment of the present invention.

Detailed Description

The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

16页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种串行通信设备地址设置的方法和系统

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类