CN109240613A - Data cache method, device, computer equipment and storage medium - Google Patents
Data cache method, device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN109240613A CN109240613A CN201810997275.5A CN201810997275A CN109240613A CN 109240613 A CN109240613 A CN 109240613A CN 201810997275 A CN201810997275 A CN 201810997275A CN 109240613 A CN109240613 A CN 109240613A
- Authority
- CN
- China
- Prior art keywords
- cache
- caching
- cache object
- target
- data
- 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.)
- Withdrawn
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0602—Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
- G06F3/061—Improving I/O performance
- G06F3/0611—Improving I/O performance in relation to response time
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0629—Configuration or reconfiguration of storage systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0638—Organizing or formatting or addressing of data
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0655—Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
- G06F3/0656—Data buffering arrangements
Abstract
The embodiment of the present application provides a kind of data cache method, device, computer equipment and storage medium.The described method includes: detecting application program launching, caching component is initialized, caching component includes cache manager and caching feeder;Cache object in instantiation caching feeder, and the cache object after instantiation is saved to cache manager;If receiving the request for obtaining target data, search whether that there are target cache objects according to the cache object title in request;Target cache object if it exists, whether judge target cache object has been more than corresponding caching life cycle there are the time;It is data cached corresponding to target cache object in reading cache manager if being less than corresponding caching life cycle, corresponding data cached conduct target data is returned.The embodiment of the present application saves the resource of access database or third party system etc., reduces the time for obtaining data, improves the efficiency for obtaining data.
Description
Technical field
This application involves technical field of data processing more particularly to a kind of data cache method, device, computer equipment and
Storage medium.
Background technique
Have configuration datas (preconfigured data) much more very in operation system, be stored in relevant database or
In person's third party system, the probability of this configuration data variation is very low, it may be said that be a kind of data of static, as province, city,
The data such as county.When needing the configuration data in business demand, if looked into database or third party system every time
It askes, the resource of third party system and database can be wasted.The resource such as connecting with Database, is looked into the database
The resource etc. needed when inquiry.Especially in the operation system of non-mass data amount caching, using NoSQL (Not Only SQL)
When technology, in the complexity and maintenance cost for carrying out will increase server when the inquiry of configuration data.
Summary of the invention
The embodiment of the present application provides a kind of data cache method, device, computer equipment and storage medium, can save access
The resource of database or third party system reduces the time for obtaining data, improves the efficiency for obtaining data.
In a first aspect, the embodiment of the present application provides a kind of data cache method, this method comprises:
Detect application program launching, initialize preset caching component, the caching component include cache manager and
Cache feeder;Instantiate the cache object in the caching feeder, wherein the cache object includes cache object name
Claim, caching life cycle, cache object creation time;Cache object after instantiation is saved into the cache manager;
If receiving the request for obtaining target data, searched from the cache manager according to the cache object title in the request
With the presence or absence of target cache object corresponding to the cache object title;The target cache object if it exists, according to current
Whether what time and caching object creation time judged the target cache object has been more than that corresponding caching is raw there are the time
Order the period;If the target cache object is less than corresponding caching life cycle there are the time, the caching pipe is read
It is data cached corresponding to target cache object described in reason device, corresponding data cached conduct target data is returned
It returns.
Second aspect, the embodiment of the present application provide a kind of data buffer storage device, which includes for executing above-mentioned
The corresponding unit of method described in one side.
The third aspect, the embodiment of the present application provide a kind of computer equipment, and the computer equipment includes memory, with
And the processor being connected with the memory;
The memory is for storing computer program, and the processor is for running the calculating stored in the memory
Machine program, to execute method described in above-mentioned first aspect.
Fourth aspect, the embodiment of the present application provide a kind of storage medium, and the storage medium is stored with computer program,
When the computer program is executed by processor, method described in above-mentioned first aspect is realized.
The embodiment of the present application is by the way that cache object to be stored in cache manager, when accessing the cache object next time,
If cache object is not out of date, directly obtain from cache manager data cached corresponding to the cache object, so saves
The resource for accessing database or third party system etc. reduces the time for obtaining data, improves the efficiency for obtaining data.
Detailed description of the invention
Technical solution in ord to more clearly illustrate embodiments of the present application, below will be to needed in embodiment description
Attached drawing is briefly described, it should be apparent that, the accompanying drawings in the following description is some embodiments of the present application, general for this field
For logical technical staff, without creative efforts, it is also possible to obtain other drawings based on these drawings.
Fig. 1 is the application scenarios schematic diagram of data cache method provided by the embodiments of the present application;
Fig. 2 is the flow diagram of data cache method provided by the embodiments of the present application;
Fig. 3 is the structural schematic diagram of caching component provided by the embodiments of the present application;
Fig. 4 is the sub-process schematic diagram of data cache method provided by the embodiments of the present application;
Fig. 5 is the flow diagram for the data cache method that another embodiment of the application provides;
Fig. 6 is the schematic block diagram of data buffer storage device provided by the embodiments of the present application;
Fig. 7 is the schematic block diagram of instantiating unit provided by the embodiments of the present application;
Fig. 8 is the schematic block diagram for the data buffer storage device that another embodiment of the application provides.
Fig. 9 is a kind of schematic block diagram of computer equipment provided by the embodiments of the present application.
Specific embodiment
Below in conjunction with the attached drawing in the embodiment of the present application, technical solutions in the embodiments of the present application carries out clear, complete
Site preparation description, it is clear that described embodiment is some embodiments of the present application, instead of all the embodiments.Based on this Shen
Please in embodiment, every other implementation obtained by those of ordinary skill in the art without making creative efforts
Example, shall fall in the protection scope of this application.
Fig. 1 is the application scenarios schematic diagram of data cache method provided by the embodiments of the present application.Applied field as shown in Figure 1
Jing Zhong, including terminal and server end.Server end includes application program, there is preset caching component in application program, caching
Some data cached, such as configuration data is stored in component.It should be noted that configuration data is one such number
According to being also stored with some other static datas etc. similar with configuration data in caching component.Below for convenience of description, will
These data are all referred to as target data.It should be noted that the application program of server end can be all kinds of application programs,
Including system, Android application program, html5 small routine, exe program etc..Wherein, data cache method is applied to server end,
The server end can integrate the arbitrary data buffer storage in the embodiment of the present application.The terminal can be desktop computer, plate
The equipment that computer, personal digital assistant (PDA), smart phone etc. can be communicated with each other with the application program of server end, herein
It is not particularly limited.In Fig. 1, terminal and server is one, it is possible to understand that ground, in actual application, terminal and
Server can have more.
In Fig. 1, terminal to server end sends the request for obtaining target data, includes cache object name in the request
Claim, after the request of received server-side to terminal, target data is returned to according to cache object title.
The data cache method for being applied to server end in the application is done below in conjunction with Figure of description and is situated between in detail
It continues.
Fig. 2 is the flow diagram of data cache method provided by the embodiments of the present application.As shown in Fig. 2, this method includes
S201-S209。
S201 detects application program launching, initializes preset caching component, and the caching component includes cache management
Device and caching feeder.
Wherein, preset caching component is for managing all objects in caching component.It is defined in caching component
Cache all methods and all properties of parent, wherein caching parent can self-defining according to the demand of user, cache in parent
The method for including data cached attribute and realizing caching, to realize function involved in data buffer storage.It is fixed to cache feeder
Justice caching subclass caches the caching subclass in feeder and inherits the method and attribute for caching parent in the present embodiment, can
To handle data cached.Caching feeder can be defined by each developer oneself, mainly realize data cached add
Logic is carried, is packaged into cache object for data cached, and parameter configuration etc. is carried out to cache object.It is also understood that slow
Feeder is deposited for providing cache object.Cache manager is a part of caching component, and cache manager is for saving caching
Cache object in feeder.The design pattern of cache manager is singleton pattern, it is meant that only one in caching component is slow
Deposit manager.The design pattern for caching feeder is stencil design mode, it is meant that has multiple caching feeders in caching component.
Specifically, the structure of caching component is as shown in Figure 3.
Initialize preset caching component, include initialization caching component itself, initialization cache manager and just
The each caching feeder of beginningization, namely instantiation caching component corresponding to object, instantiation cache manager corresponding to pair
As and each caching feeder of instantiation corresponding to object.It is to be appreciated that in practical applications, cache manager and caching
Feeder is all specific object, such as java object.Initializing preset caching component is when detecting application program launching
It carries out.Server restarts the application program after loading and starting the application program and server delay machine for the first time
When, it can all initialize preset caching component.
If the caching component is the caching component realized based on Spring frame, when initializing caching component, configuration is obtained
The object of instantiation, the object as corresponding to caching component, object corresponding to cache manager, caching feeder are needed in file
Corresponding object etc. calls directly the instantiation method in Spring frame, without rewriting instantiation method, adds
The fast speed of instantiation.
S202, instantiate it is described caching feeder in cache object, wherein cache object include cache object title,
Cache life cycle, cache object creation time.
Can provide in caching feeder need to cache data cached, then protect the data cached object that is packaged into
It deposits.It is data cached corresponding to being determined by specific business demand in each caching feeder, therefore each caching feeder
In it is corresponding it is data cached may be all different.
In one embodiment, as shown in figure 4, step S202 includes S401-S403.
S401, acquisition need to cache data cached.The demand of the specific business of data cached basis that need to be cached is determined, business
Any data is needed, then needing what data the data cached of caching is exactly.Such as national province, city, county's data, rule in group
The data such as fixed type of service.Data cached can be that need to be cached is inquired by database, can be acquisition
The data that are such as obtained from third party system of third party's data, other data etc. being also possible in the server obtained.Only
If the data of business demand, at the same it is available arrive, can be as being data cached then can be carried out caching.
S402, by it is described it is data cached be packaged, to form cache object.Such as a certain data are packaged by data cached
Structure.For data cached in different business demand, required data structure can be packaged into.Due to caching feeder
It is by the caching subclass of the succession parent of each developer oneself definition, therefore the business demand realized according to each developer
Different data cached encapsulation can be achieved.The data object after encapsulating will be completed as cache object.
S403, is arranged the parameter of cache object, and the parameter includes cache object title, caching life cycle, caching pair
As creation time.The time for forming cache object in server by obtaining, using the time as the creation time of cache object.
Cache the existence timeliness of life cycle namely cache object.Cache object is effective in caching life cycle, if being more than slow
Life cycle is deposited, which is considered invalid.
Content corresponding to Fig. 4 embodiment can be encapsulated in instantiation method, in GetData method.It is incited somebody to action with realizing
Cache object in caching feeder is instantiated.
S203 saves the cache object after instantiation into the cache manager.
After cache object in instantiation caching feeder, the cache object after instantiation is sent to cache manager.
Cache manager calls store method, and corresponding cache object is saved.It should be noted that only inheriting caching parent
Subclass corresponding to object, can just save into cache manager.
Step process when above step S201-S203 is application program launching, it is possible to understand that ground, when application program launching
Cache object corresponding in feeder will be actively cached to save into cache manager.When using cache object for next time,
Data corresponding to the cache object are directly read from cache manager, in this way, needs need not be obtained from database again
Data or the data etc. that needs are obtained from third party system save the resource of access database, third party system etc., reduce
The time for obtaining data improves the efficiency for obtaining data.
S204 delays according to the cache object title in the request from described if receiving the request for obtaining target data
It deposits and searches whether that there are target cache objects corresponding to the cache object title in manager.
Wherein, the request for obtaining target data can be by terminal transmission.In other embodiments, it is also possible to by taking
What other modules of device end of being engaged in were sent.Obtaining in the request of target data includes cache object title.Wherein, target data is slow
Deposit the corresponding data that target cache object corresponding to object oriented is saved.According to cache object title from cache manager
In search whether that there are the target cache objects.The target cache object if it exists executes step S205;The target if it does not exist
Cache object executes step S207.
S205, according to current time and caching object creation time judge the target cache object there are the time whether
It has been more than corresponding caching life cycle.
Specifically, step S205 includes: to obtain current time in server, delay corresponding to the target cache object
Deposit object creation time and corresponding caching life cycle;Current time is subtracted into the cache object creation time to obtain
Time interval;Judge whether the time interval is greater than corresponding caching life cycle;If more than corresponding caching life
In the period, determine the target cache object has been more than corresponding caching life cycle there are the time;If no more than corresponding
Caching life cycle, determine the target cache object is less than corresponding caching life cycle there are the time.Wherein,
Current time refers to system time, and quickly due to processor processing speed, current time can be understood as detecting the presence of mesh
Mark system time corresponding when the time of cache object.
If the target cache object is less than corresponding caching life cycle there are the time, step S206 is executed;
If the target cache object has been more than corresponding caching life cycle there are the time, step S207 is executed.
S206, read it is data cached corresponding to target cache object described in the cache manager, will be corresponding
It is data cached to be returned as target data.Process terminates.
If being less than corresponding caching life cycle, it is meant that the target cache object is not out of date or effective.So
It is data cached corresponding to the target cache object in reading cache manager, this is data cached as target data return.
In this way, directly obtaining target data from caching, reduce the time for obtaining data, improves the efficiency for obtaining data.
S207 instantiates the target cache object.The even described target cache object is more than corresponding there are the time
If caching life cycle or the cache manager in be not present the target cache object, instantiate the target cache
Object.
If being more than corresponding caching life cycle, it is meant that the target cache object is expired or invalid.If should
Target cache object is expired or invalid, then needing to update the target cache object.Specific update method are as follows: example
Change the target cache object, the target cache object after instantiation is saved into cache manager again.If cache management
The target cache object is not present in device, also needs instantiation target cache object, the target cache object after instantiating is protected
It deposits into cache manager.It is to be understood that if the target cache object is not present in cache manager, in cache manager
The target cache object is increased newly, so as to store in cache manager more data cached.Specifically instantiation method please refers to
Method described in Fig. 3 embodiment, details are not described herein.
S208 saves the target cache object after instantiation into the cache manager.
S209 is used as target data to return for data cached corresponding to the target cache object.
Above method embodiment is by initializing preset caching component in application program launching, in cache manager
The middle cache object saved in caching feeder, if cache object is not out of date, is directly postponed when accessing the cache object next time
Deposit obtained in manager it is data cached corresponding to the cache object.If cache object is out of date, the cache object is updated, so as to
It can directly obtain from cache manager when accessing the cache object in caching life cycle and delay corresponding to the cache object
Deposit data.If cache object is not present in cache manager, the cache object is increased newly in cache manager, to give birth in caching
It can directly be obtained from cache manager when accessing the cache object in the life period data cached corresponding to the cache object.Such as
This saves the resource of access database, third party system etc., reduces the time for obtaining data, improves the effect for obtaining data
Rate.
In other embodiments, although caching feeder defines cache class, which may not be to inherit to delay
Deposit the subclass of parent.Object corresponding to the subclass of caching parent is only inherited, can just be saved into cache manager, such as
This needs to judge cache class corresponding to the cache object after instantiating in caching feeder.Fig. 5 is that the application is another
The flow diagram for the data cache method that embodiment provides.As shown in figure 5, this method includes S501-S513.The embodiment institute
The difference of corresponding step and step corresponding to Fig. 2 embodiment is: increasing step S503-S504, S510-S511.Under
Face will be described in detail step S503-S504, S510-S511, other steps please refer to description corresponding to Fig. 2 embodiment, herein
It repeats no more.
S503, judges whether cache class corresponding to the cache object after instantiating inherits in the caching component
The caching parent of definition.
Specifically, the cache object after instantiation is obtained, it, can since object is all that instantiation comes out from class
To obtain cache class corresponding to the cache object, judge whether cache class corresponding to the cache object inherits the caching
Parent is cached defined in component, such as can be judged by the keyword that the extend expression obtained in code is inherited,
Illustratively, if there are the keywords that the expressions such as extend are inherited in code, then it represents that inherit and delay defined in caching component
Deposit parent;Conversely, not inheriting then.It should be noted that can also be judged by other feasible modes, specifically herein
Without limitation.
If cache class corresponding to the cache object is not inherited and caches parent defined in the caching component, step is executed
Rapid S504;If cache class corresponding to the cache object inherits and caches parent defined in the caching component, step is executed
Rapid S505.
S504 does not save the cache object into the cache manager.Such as the cache object can temporarily be protected
It deposits in memory.
S505 saves the cache object after instantiation into the cache manager.
S510, judges whether cache class corresponding to the target cache object after instantiating inherits the caching group
Parent is cached defined in part.If cache class corresponding to the target cache object is not inherited defined in the caching component
Parent is cached, step S511 is executed;If cache class corresponding to the target cache object inherits fixed in the caching component
The caching parent of justice executes step S512.
S511 does not save the target cache object into the cache manager.It such as can be by the target cache pair
As being stored temporarily in memory.Then step S513 is executed, by data cached conduct corresponding to the target cache object
Target data is returned.
S512 saves the target cache object after instantiation into the cache manager.
S513 is used as target data to return for data cached corresponding to the target cache object.
Whether above method embodiment inherits the caching to cache class corresponding to the cache object after instantiation
Caching parent defined in component is judged, the cache object for inheriting caching parent is saved to cache manager
In, and filter some cache objects without inheriting caching parent.
In above method embodiment need caching data can be preconfigured data, or with configuration data class
As other static datas etc..Wherein, the static data at this can be regarded as the data that will not be modified in the long period, such as the whole nation
The data such as province, city, county, the data such as street in each area, the data such as defined type of service in group.
Fig. 6 is the schematic block diagram of data buffer storage device provided by the embodiments of the present application.As shown in figure 5, more than corresponding to
Data cache method, the application also provide a kind of data buffer storage device.The device can be configured in desktop computer, plate electricity
The server ends such as brain, laptop computer.Specifically, as shown in fig. 6, the device 60 includes initialization unit 601, instantiating unit
602, storage unit 603, searching unit 604, caching judging unit 605 and return unit 606.
Initialization unit 601 initializes preset caching component, the caching group for detecting application program launching
Part includes cache manager and caching feeder.
Instantiating unit 602, for instantiating the cache object in the caching feeder, wherein cache object includes
Cache object title, caching life cycle, cache object creation time.
Storage unit 603, for saving the cache object after instantiation into the cache manager.
Searching unit 604, if for receiving the request for obtaining target data, according to the cache object name in the request
Title searches whether that there are target cache objects corresponding to the cache object title from the cache manager;
Judging unit 605 is cached, for the target cache object if it exists, according to current time and caching Object Creation
Whether what the time judged the target cache object has been more than corresponding caching life cycle there are the time.
In one embodiment, caching judging unit 605 include time acquisition unit, subtract each other unit, time judging unit with
And determination unit.Wherein, time acquisition unit, for obtain the current time in server, the target cache object institute it is right
The cache object creation time and corresponding caching life cycle answered.Subtract each other unit, it is described slow for subtracting current time
Object creation time is deposited to obtain time interval.Time judging unit, for judging it is corresponding whether the time interval is greater than
Caching life cycle.Determination unit determines the mesh if being greater than corresponding caching life cycle for the time interval
Mark cache object has been more than corresponding caching life cycle there are the time;If the time interval is delayed no more than corresponding
Life cycle is deposited, determine the target cache object is less than corresponding caching life cycle there are the time.
Return unit 606, if being less than corresponding caching Life Cycle there are the time for the target cache object
Phase, read it is data cached corresponding to target cache object described in the cache manager, by corresponding data cached work
It is returned for target data.
Instantiating unit 602, if be also used to the target cache object is more than corresponding caching life there are the time
If the target cache object is not present in period or the cache manager, the target cache object is instantiated.
Storage unit 603 is also used to save the target cache object after instantiation into the cache manager.
Return unit 606, being also used to will be data cached as target data progress corresponding to the target cache object
It returns.
Wherein, as shown in fig. 7, instantiating unit 602 includes data cached acquiring unit 701, encapsulation unit 702 and sets
Set unit 703.Wherein, data cached acquiring unit 701, for obtain need to cache it is data cached.Encapsulation unit 702, is used for
By it is described it is data cached be packaged, to form cache object or target cache object.Setting unit 703, it is slow for being arranged
The parameter of object or target cache object is deposited, the parameter includes cache object title, caching life cycle, cache object wound
Build the time.
In other embodiments, although caching feeder defines cache class, which may not be to inherit to delay
Deposit the subclass of parent.Object corresponding to the subclass of caching parent is only inherited, can just be saved into cache manager, such as
This needs to judge cache class corresponding to the cache object after instantiating in caching feeder.Fig. 8 is that the application is another
The schematic block diagram for the data buffer storage device that embodiment provides.The device 80 include initialization unit 801, instantiating unit 802,
Inherit judging unit 803, storage unit 804, searching unit 805, caching judging unit 806 and return unit 807.This implementation
The device of example is to increase to inherit judging unit 804 on the basis of the above embodiments.Other units please refer to above-described embodiment
Description, details are not described herein.
Judging unit 804 is inherited, for judging corresponding to the cache object or target cache object after instantiating
Cache class whether inherit and cache parent defined in the caching component.
Storage unit 804 caches parent if being also used to inherit defined in the caching component, by the institute after instantiation
It states cache object or target cache object is saved into the cache manager;If not inheriting defined in the caching component
Parent is cached, then is not saved the cache object or target cache object into the cache manager.
It should be noted that it is apparent to those skilled in the art that, the tool of above-mentioned apparatus and each unit
Body realizes process, can be no longer superfluous herein with reference to the corresponding description in preceding method embodiment, for convenience of description and succinctly
It states.
Above-mentioned apparatus can be implemented as a kind of form of computer program, and computer program can be in meter as shown in Figure 9
It calculates and is run on machine equipment.
Fig. 9 is a kind of schematic block diagram of computer equipment provided by the embodiments of the present application.The equipment can be server.
Wherein, server can be desktop computer, tablet computer, laptop computer etc..The equipment 90 includes being connected by system bus 901
Processor 902, memory and network interface 903, wherein memory may include non-volatile memory medium 904 and memory
Reservoir 905.
The non-volatile memory medium 904 can storage program area 9041 and computer program 9042.This is non-volatile to deposit
, it can be achieved that data cache method described above when the computer program 9042 stored in storage media is executed by processor 902.
The processor 902 supports the operation of whole equipment 90 for providing calculating and control ability.The built-in storage 905 is non-volatile
Property storage medium in computer program operation provide environment, the computer program by processor 902 execute when, may make place
Reason device 902 executes data cache method described above.The network interface 903 is for carrying out network communication.Those skilled in the art
Member is appreciated that structure shown in Fig. 9, only the block diagram of part-structure relevant to application scheme, composition pair
The restriction for the equipment 90 that application scheme is applied thereon, specific equipment 90 may include more more or less than as shown in the figure
Component, perhaps combine certain components or with different component layouts.
Wherein, the processor 902 is for running computer program stored in memory, to realize following steps:
Detect application program launching, initialize preset caching component, the caching component include cache manager and
Cache feeder;Instantiate the cache object in the caching feeder, wherein cache object includes cache object title, delays
Deposit life cycle, cache object creation time;Cache object after instantiation is saved into the cache manager;If receiving
To the request for obtaining target data, search whether to deposit from the cache manager according to the cache object title in the request
The target cache object corresponding to the cache object title;The target cache object if it exists, according to current time and
Whether what cache object creation time judged the target cache object has been more than corresponding caching life cycle there are the time;
If the target cache object is less than corresponding caching life cycle there are the time, institute in the cache manager is read
It states data cached corresponding to cache object, data cached is returned corresponding as target data.
In one embodiment, the processor 902 is also implemented as follows step:
If if the target cache object is more than that corresponding caching life cycle or the caching are managed there are the time
It manages and the target cache object is not present in device, instantiate the target cache object;By the target cache after instantiation
Object is saved into the cache manager;It will be data cached as target data progress corresponding to the target cache object
It returns.
In one embodiment, the processor 902 is when executing the instantiation target cache object, specific implementation
Following steps:
Acquisition need to cache data cached;By it is described it is data cached be packaged, to form target cache object;Mesh is set
The parameter of cache object is marked, the parameter includes cache object title, caching life cycle, cache object creation time.
In one embodiment, the processor 902 is saved in the execution cache object by after instantiation to institute
Before stating in cache manager, it is also implemented as follows step:
Whether cache class corresponding to the cache object after judging instantiation inherits defines in the caching component
Caching parent;If inheriting and caching parent defined in the caching component, the caching by after instantiation is executed
Object saves the step into the cache manager;Parent is cached defined in the caching component if not inheriting, will not
The cache object is saved into the cache manager.
In one embodiment, the processor 902 execute it is described according to current time and caching object creation time sentence
Break when whether being more than corresponding caching life cycle there are the time of the target cache object, is implemented as follows step
It is rapid:
Cache object creation time corresponding to current time, the target cache object in acquisition server and institute are right
The caching life cycle answered;Current time is subtracted into corresponding cache object creation time to obtain time interval;Judge institute
State whether time interval is greater than corresponding caching life cycle;If more than corresponding caching life cycle, the mesh is determined
Mark cache object has been more than corresponding caching life cycle there are the time;If being not more than corresponding caching life cycle,
Determine the target cache object is less than corresponding caching life cycle there are the time.
It should be appreciated that in the embodiment of the present application, alleged processor 902 can be central processing unit (Central
Processing Unit, CPU), which can also be other general processors, digital signal processor (Digital
Signal Processor, DSP), specific integrated circuit (application program lication Specific Integrated
Circuit, ASIC), ready-made programmable gate array (Field-Programmable Gate Array, FPGA) or other can
Programmed logic device, discrete gate or transistor logic, discrete hardware components etc..General processor can be microprocessor
Or the processor is also possible to any conventional processor etc..
Those of ordinary skill in the art will appreciate that be realize above-described embodiment method in all or part of the process,
It is that relevant hardware can be instructed to complete by computer program.The computer program can be stored in a storage medium,
The storage medium can be computer readable storage medium.The computer program is by the processing of at least one of the computer system
Device executes, to realize the process step of the embodiment of the above method.
Therefore, present invention also provides a kind of storage mediums.The storage medium can be computer readable storage medium.It should
Storage medium is stored with computer program, which performs the steps of when being executed by a processor
Detect application program launching, initialize preset caching component, the caching component include cache manager and
Cache feeder;Instantiate the cache object in the caching feeder, wherein cache object includes cache object title, delays
Deposit life cycle, cache object creation time;Cache object after instantiation is saved into the cache manager;If receiving
To the request for obtaining target data, search whether to deposit from the cache manager according to the cache object title in the request
The target cache object corresponding to the cache object title;The target cache object if it exists, according to current time and
Whether what cache object creation time judged the target cache object has been more than corresponding caching life cycle there are the time;
If the target cache object is less than corresponding caching life cycle there are the time, institute in the cache manager is read
It states data cached corresponding to target cache object, data cached is returned corresponding as target data.
In one embodiment, the processor is also implemented as follows step:
If if the target cache object is more than that corresponding caching life cycle or the caching are managed there are the time
It manages and the target cache object is not present in device, instantiate the target cache object;By the target cache after instantiation
Object is saved into the cache manager;It will be data cached as target data progress corresponding to the target cache object
It returns.
In one embodiment, for the processor when executing the instantiation target cache object, specific implementation is such as
Lower step:
Acquisition need to cache data cached;By it is described it is data cached be packaged, to form target cache object;Mesh is set
The parameter of cache object is marked, the parameter includes cache object title, caching life cycle, cache object creation time.
In one embodiment, the processor is saved in the execution cache object by after instantiation to described slow
Before depositing in manager, it is also implemented as follows step:
Whether cache class corresponding to the cache object after judging instantiation inherits defines in the caching component
Caching parent;If inheriting and caching parent defined in the caching component, the caching by after instantiation is executed
Object saves the step into the cache manager;Parent is cached defined in the caching component if not inheriting, will not
The cache object is saved into the cache manager.
In one embodiment, the processor execute it is described according to current time and caching object creation time judge institute
When whether being more than corresponding caching life cycle there are the time of target cache object is stated, step is implemented as follows:
Cache object creation time corresponding to current time, the target cache object in acquisition server and institute are right
The caching life cycle answered;Current time is subtracted into corresponding cache object creation time to obtain time interval;Judge institute
State whether time interval is greater than corresponding caching life cycle;If more than corresponding caching life cycle, the mesh is determined
Mark cache object has been more than corresponding caching life cycle there are the time;If being not more than corresponding caching life cycle,
Determine the target cache object is less than corresponding caching life cycle there are the time.
The storage medium can be USB flash disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), magnetic disk
Or the various computer readable storage mediums that can store program code such as CD.
In several embodiments provided herein, it should be understood that disclosed device, device and method, it can be with
It realizes by another way.For example, the apparatus embodiments described above are merely exemplary, the division of the unit,
Only a kind of logical function partition, there may be another division manner in actual implementation.Those skilled in the art can be with
It is well understood, for convenience of description and succinctly, the specific work process of the device of foregoing description, equipment and unit can
With with reference to the corresponding process in preceding method embodiment, details are not described herein.The above, the only specific embodiment party of the application
Formula, but the protection scope of the application is not limited thereto, and anyone skilled in the art discloses in the application
In technical scope, various equivalent modifications or substitutions can be readily occurred in, these modifications or substitutions should all cover the guarantor in the application
Within the scope of shield.Therefore, the protection scope of the application should be subject to the protection scope in claims.
Claims (10)
1. a kind of data cache method, which is characterized in that the described method includes:
It detects application program launching, initializes preset caching component, the caching component includes cache manager and caching
Feeder;
Instantiate the cache object in the caching feeder, wherein the cache object includes cache object title, caching life
Order period, cache object creation time;
Cache object after instantiation is saved into the cache manager;
If the request for obtaining target data is received, according to the cache object title in the request from the cache manager
Search whether that there are target cache objects corresponding to the cache object title;
The target cache object if it exists judges the target cache object according to current time and caching object creation time
Whether be more than corresponding caching life cycle there are the time;
If the target cache object is less than corresponding caching life cycle there are the time, the cache manager is read
Described in it is data cached corresponding to target cache object, data cached returned corresponding as target data.
2. the method according to claim 1, wherein the method also includes:
If if the target cache object is more than corresponding caching life cycle or the cache manager there are the time
In be not present the target cache object, instantiate the target cache object;
The target cache object after instantiation is saved into the cache manager;
It is used as target data to return for data cached corresponding to the target cache object.
3. according to the method described in claim 2, it is characterized in that, instantiating the target cache object, comprising:
Acquisition need to cache data cached;
By it is described it is data cached be packaged, to form target cache object;
The parameter of target cache object is set, and the parameter includes cache object title, caching life cycle, cache object creation
Time.
4. the method according to claim 1, wherein the cache object by after instantiation save to
Before in the cache manager, the method also includes:
Whether cache class corresponding to the cache object after judging instantiation inherits is delayed defined in the caching component
Deposit parent;
If inheriting and caching parent defined in the caching component, executes the cache object by after instantiation and save
To the step in the cache manager.
5. the method according to claim 1, wherein described sentence according to current time and caching object creation time
Whether break the target cache object has been more than corresponding caching life cycle there are the time, comprising:
Obtain the current time in server, cache object creation time corresponding to the target cache object and corresponding
Cache life cycle;
Current time is subtracted into corresponding cache object creation time to obtain time interval;
Judge whether the time interval is greater than corresponding caching life cycle;
If more than corresponding caching life cycle, determine the target cache object has been more than corresponding delay there are the time
Deposit life cycle;If being not more than corresponding caching life cycle, determine the target cache object there are the times to be less than
Corresponding caching life cycle.
6. a kind of data buffer storage device, which is characterized in that the data buffer storage device includes:
Initialization unit initializes preset caching component, the caching component includes slow for detecting application program launching
Deposit manager and caching feeder;
Instantiating unit, for instantiating the cache object in the caching feeder, wherein cache object includes cache object
Title, caching life cycle, cache object creation time;
Storage unit, for saving the cache object after instantiation into the cache manager;
Searching unit, if for receiving the request for obtaining target data, according to the cache object title in the request from institute
It states and searches whether that there are target cache objects corresponding to the cache object title in cache manager;
Judging unit is cached, for the target cache object if it exists, is sentenced according to current time and caching object creation time
Whether break the target cache object has been more than corresponding caching life cycle there are the time;
Return unit is read if being less than corresponding caching life cycle there are the time for the target cache object
It is data cached corresponding to target cache object described in the cache manager, data cached number of targets is used as corresponding
According to being returned.
7. data buffer storage device according to claim 6, it is characterised in that:
The instantiating unit, if be also used to the target cache object is more than corresponding caching life cycle there are the time
If there is no the target cache objects in the cache manager, instantiate the target cache object;
The storage unit is also used to save the target cache object after instantiation into the cache manager;
The return unit is also used to be used as target data to return for data cached corresponding to the target cache object
It returns.
8. data buffer storage device according to claim 6, which is characterized in that the data buffer storage device further include:
Judging unit is inherited, for judging it is described slow whether cache class corresponding to the cache object after instantiating inherits
It deposits and caches parent defined in component;
The storage unit inherits defined in the caching component if being also used to cache class corresponding to the cache object
Parent is cached, the cache object by after instantiation is saved into the cache manager.
9. a kind of computer equipment, which is characterized in that the computer equipment includes memory, and is connected with the memory
Processor;
The memory is for storing computer program;The processor is for running the computer journey stored in the memory
Sequence, to execute the method according to claim 1 to 5.
10. a kind of storage medium, which is characterized in that the storage medium is stored with computer program, the computer program quilt
When processor executes, the method according to claim 1 to 5 is realized.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810997275.5A CN109240613A (en) | 2018-08-29 | 2018-08-29 | Data cache method, device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810997275.5A CN109240613A (en) | 2018-08-29 | 2018-08-29 | Data cache method, device, computer equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN109240613A true CN109240613A (en) | 2019-01-18 |
Family
ID=65069477
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810997275.5A Withdrawn CN109240613A (en) | 2018-08-29 | 2018-08-29 | Data cache method, device, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109240613A (en) |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110018969A (en) * | 2019-03-08 | 2019-07-16 | 平安科技(深圳)有限公司 | Data cache method, device, computer equipment and storage medium |
CN110750566A (en) * | 2019-10-24 | 2020-02-04 | 广州欢聊网络科技有限公司 | Data processing method and device, cache system and cache management platform |
WO2020215833A1 (en) * | 2019-04-26 | 2020-10-29 | 创新先进技术有限公司 | Offline cache method and apparatus, and terminal and readable storage medium |
US10880583B2 (en) | 2019-04-26 | 2020-12-29 | Advanced New Technologies Co., Ltd. | Method, apparatus, terminal, and readable storage medium for offline caching |
CN112948336A (en) * | 2021-03-30 | 2021-06-11 | 联想凌拓科技有限公司 | Data acceleration method, cache unit, electronic device and storage medium |
CN113626483A (en) * | 2021-08-18 | 2021-11-09 | 重庆允成互联网科技有限公司 | Front-end caching method, system, equipment and storage medium for filling forms |
CN113703874A (en) * | 2021-09-06 | 2021-11-26 | 深信服科技股份有限公司 | Data stream processing method, device, equipment and readable storage medium |
CN115269660A (en) * | 2022-09-26 | 2022-11-01 | 平安银行股份有限公司 | Cache data processing method and device, electronic equipment and storage medium |
-
2018
- 2018-08-29 CN CN201810997275.5A patent/CN109240613A/en not_active Withdrawn
Cited By (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110018969A (en) * | 2019-03-08 | 2019-07-16 | 平安科技(深圳)有限公司 | Data cache method, device, computer equipment and storage medium |
CN110018969B (en) * | 2019-03-08 | 2023-06-02 | 平安科技(深圳)有限公司 | Data caching method, device, computer equipment and storage medium |
WO2020215833A1 (en) * | 2019-04-26 | 2020-10-29 | 创新先进技术有限公司 | Offline cache method and apparatus, and terminal and readable storage medium |
US10880583B2 (en) | 2019-04-26 | 2020-12-29 | Advanced New Technologies Co., Ltd. | Method, apparatus, terminal, and readable storage medium for offline caching |
CN110750566A (en) * | 2019-10-24 | 2020-02-04 | 广州欢聊网络科技有限公司 | Data processing method and device, cache system and cache management platform |
CN112948336A (en) * | 2021-03-30 | 2021-06-11 | 联想凌拓科技有限公司 | Data acceleration method, cache unit, electronic device and storage medium |
CN112948336B (en) * | 2021-03-30 | 2023-01-03 | 联想凌拓科技有限公司 | Data acceleration method, cache unit, electronic device and storage medium |
CN113626483A (en) * | 2021-08-18 | 2021-11-09 | 重庆允成互联网科技有限公司 | Front-end caching method, system, equipment and storage medium for filling forms |
CN113626483B (en) * | 2021-08-18 | 2022-04-26 | 重庆允成互联网科技有限公司 | Front-end caching method, system, equipment and storage medium for filling forms |
CN113703874A (en) * | 2021-09-06 | 2021-11-26 | 深信服科技股份有限公司 | Data stream processing method, device, equipment and readable storage medium |
CN113703874B (en) * | 2021-09-06 | 2023-09-05 | 深信服科技股份有限公司 | Data stream processing method, device, equipment and readable storage medium |
CN115269660A (en) * | 2022-09-26 | 2022-11-01 | 平安银行股份有限公司 | Cache data processing method and device, electronic equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109240613A (en) | Data cache method, device, computer equipment and storage medium | |
US8788760B2 (en) | Adaptive caching of data | |
US9544726B2 (en) | Adding location names using private frequent location data | |
US9372898B2 (en) | Enabling event prediction as an on-device service for mobile interaction | |
CN109766349B (en) | Task duplicate prevention method, device, computer equipment and storage medium | |
US20150379035A1 (en) | On-Demand Caching in a WAN Separated Distributed File System or Clustered File System Cache | |
US11366809B2 (en) | Dynamic creation and configuration of partitioned index through analytics based on existing data population | |
CN107077691A (en) | The strategy based on the age for determining database cache hit | |
CN109614347B (en) | Processing method and device for multi-level cache data, storage medium and server | |
CN110677462B (en) | Access processing method, system, device and storage medium for multi-block chain network | |
CN104950757A (en) | Container monitoring method and system | |
CN107016027A (en) | The method and apparatus for realizing business information fast search | |
CN107958018B (en) | Method and device for updating data in cache and computer readable medium | |
CN104331444A (en) | Method and device for protecting database | |
CN107820611A (en) | Event handling system paging | |
CN110442773A (en) | Distributed system interior joint caching method, system, device and computer media | |
US10242102B2 (en) | Network crawling prioritization | |
CN109842621A (en) | A kind of method and terminal reducing token storage quantity | |
CN109753243A (en) | Copy dispositions method, Cloud Server and storage medium | |
CN113364877A (en) | Data processing method, device, electronic equipment and medium | |
CN109240893A (en) | Using operating status querying method and terminal device | |
CN109947667B (en) | Data access prediction method and device | |
US10320896B2 (en) | Intelligent mapping for an enterprise grid | |
US9317432B2 (en) | Methods and systems for consistently replicating data | |
US9619397B2 (en) | Cost sensitive browser cache cleanup based on weighted probabilistic cached item usage |
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 | ||
WW01 | Invention patent application withdrawn after publication |
Application publication date: 20190118 |
|
WW01 | Invention patent application withdrawn after publication |