[go: up one dir, main page]

CN104331492B - A kind of method and device for caching more instance datas - Google Patents

A kind of method and device for caching more instance datas Download PDF

Info

Publication number
CN104331492B
CN104331492B CN201410648574.XA CN201410648574A CN104331492B CN 104331492 B CN104331492 B CN 104331492B CN 201410648574 A CN201410648574 A CN 201410648574A CN 104331492 B CN104331492 B CN 104331492B
Authority
CN
China
Prior art keywords
data
active instance
instance list
time
list
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.)
Active
Application number
CN201410648574.XA
Other languages
Chinese (zh)
Other versions
CN104331492A (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.)
Beijing Gridsum Technology Co Ltd
Original Assignee
Beijing Gridsum 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 Beijing Gridsum Technology Co Ltd filed Critical Beijing Gridsum Technology Co Ltd
Priority to CN201410648574.XA priority Critical patent/CN104331492B/en
Publication of CN104331492A publication Critical patent/CN104331492A/en
Application granted granted Critical
Publication of CN104331492B publication Critical patent/CN104331492B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • 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/21Design, administration or maintenance of databases
    • G06F16/217Database tuning

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Information Transfer Between Computers (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

The invention discloses a kind of method and device for caching more instance datas, established first in the internal memory of server end and safeguard an active instance list, and be only updated maintenance to being present in the data cached of all examples in the active instance list;When receiving the request of data that a certain example is sent, if the example is not found in the active instance list, then the id of the example is added in the active instance list, and corresponding time T is set to the time at current server end, and return to client corresponding to the example after inquiring about from database the data of the example.This method can either avoid the not high data cached committed memory space of utilization rate, and the expense that can also reduce cpu as far as possible connects with unnecessary database, reduces the pressure of database.

Description

A kind of method and device for caching more instance datas
Technical field
The present invention relates to technical field of data processing, more particularly to a kind of method and device for caching more instance datas.
Background technology
At present, in real time data inspecting system, client needs frequently to inquire about servers' data, usual way It is that client sends querying condition, database is inquired about after received server-side to querying condition, returned data result simultaneously passes to Client.One server serves multiple examples, and each example has oneself independent database, when more examples simultaneously During hair inquiry, one side factor data bank table constantly writes data, is likely to result in read-write interlocking and fights for resource, on the other hand exists Need to provide different data to multiple examples in one application program, if the request of client will inquire about database every time If, then whether the pressure of the pressure of database or application program is all very big.
In the prior art scheme, server end timing updates the caching required for each example, and client is asked every time All directly read data cached, such scheme is in the case where example is especially more, and the data that are cached in server end are also just especially It is more, thus cause caching pressure and the connection of unnecessary database of server end.
The content of the invention
It is an object of the invention to provide a kind of method and device for caching more instance datas, utilization rate can either be avoided not high Data cached committed memory space, also can as far as possible reduce cpu expense connect with unnecessary database, reduction database Pressure.
A kind of method for caching more instance datas, safeguards there is active instance list, the work in the internal memory of server end Field is comprised at least in jump example list:Example id and example last time request server end data time T;
Methods described includes:
When receiving the request of data that a certain example is sent, if not finding the example in the active instance list, Then the id of the example is added in the active instance list, and corresponding time T is set to the time at current server end, And return to client corresponding to the example after the data of the example are inquired about from database;
If having found the example in the active instance list, data cached by the example returns to the example Corresponding client, and update the last-minute plea time of corresponding instance in the active instance list.
After returning to client corresponding to the example after the data that the example is inquired about from database, methods described is also Including:
The data of the example inquired from database are put into caching.
Methods described also includes:
Maintenance periodically is updated to the active instance list.
It is described maintenance periodically is updated to the active instance list to be specially:
Inspect periodically the last time renewal time of each example in the active instance list;
If the last time renewal time of a certain example and the difference of current time exceed the threshold value of setting, the reality is judged Example is inactive example, and the example is deleted from the active instance list.
It is described the example is deleted from the active instance list after, in addition to:
By the data cached deletion for the example for existing in the buffer but being not present in the active instance list.
A kind of device for caching more instance datas, described device include:
Active instance list management unit, for safeguarding active instance list, comprised at least in the active instance list Field:Example id and example last time request server end data time T;
Data receipt unit, the request of data sent for receiving a certain example;
Instance data processing unit, the data that a certain example for being received according to the data receipt unit is sent please Ask and carry out lookup processing in the active instance list, specifically include:If do not find this in the active instance list Example, then the id of the example is added in the active instance list, and corresponding time T is set to current server end Time, and return to client corresponding to the example after inquiring about from database the data of the example;If in the active instance The example has been found in list, then the data cached of the example has been returned into client corresponding to the example, and described in renewal The last-minute plea time of corresponding instance in active instance list.
Described device also includes:
Data cached administrative unit, for inquiring about the data of the example from database in the instance data processing unit And after returning to client corresponding to the example, the data of the example inquired from database are put into caching.
The active instance list management unit is further used for periodically being updated maintenance to the active instance list.
The active instance list management unit further comprises updating maintenance module, described active real for inspecting periodically The last time renewal time of each example in example list;If the last time renewal time of a certain example and the difference of current time More than the threshold value of setting, then the example is judged for inactive example, and the example is deleted from the active instance list.
The updating maintenance module is additionally operable to:To in the buffer exist but be not present in the active instance list The data cached deletion of example.
As seen from the above technical solution provided by the invention, this method can either avoid the not high caching number of utilization rate According to committed memory space, the expense that can also reduce cpu as far as possible connects with unnecessary database, reduces the pressure of database.
Brief description of the drawings
In order to illustrate the technical solution of the embodiments of the present invention more clearly, required use in being described below to embodiment Accompanying drawing be briefly described, it should be apparent that, drawings in the following description are only some embodiments of the present invention, for this For the those of ordinary skill in field, on the premise of not paying creative work, other can also be obtained according to these accompanying drawings Accompanying drawing.
Fig. 1 is provided the method flow schematic diagram for caching more instance datas by the embodiment of the present invention;
Fig. 2 is provided the apparatus structure schematic diagram for caching more instance datas by the embodiment of the present invention.
Embodiment
With reference to the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, complete Ground describes, it is clear that described embodiment is only part of the embodiment of the present invention, rather than whole embodiments.Based on this The embodiment of invention, the every other implementation that those of ordinary skill in the art are obtained under the premise of creative work is not made Example, belongs to protection scope of the present invention.
The embodiment of the present invention in the internal memory of server end by adding active instance list, according to client request service The data at device end carry out the Dynamic Maintenance active instance list, and server end only enters line number to the example in the active instance list According to caching, the data cached committed memory space that utilization rate is not high is avoided, can also reduce cpu expense and unnecessary as far as possible Database connects, and reduces the pressure of database.The embodiment of the present invention is described in further detail below in conjunction with accompanying drawing, schemed 1 is provided the method flow schematic diagram for caching more instance datas by the embodiment of the present invention, and methods described includes:
Step 11:Safeguard there is active instance list in the internal memory of server end, and only to being present in the active instance The data cached of all examples in list is updated maintenance;
In this step, following field is comprised at least in the active instance list:Example id and example last time are asked The time T of servers' data.
Step 12:When receiving the request of data that a certain example is sent, active instance list is searched;
Step 13:If not finding the example in the active instance list, the id of the example is added to described In active instance list, and corresponding time T is set to the time at current server end, and the example is inquired about from database Client corresponding to the example is returned to after data;
In this step, further the data of the example inquired from database can also be put into caching, from And ensure that the example in active instance list is data cached corresponding to having.
Step 14:If having found the example in the active instance list, by the data cached return of the example To client corresponding to the example, and update the last-minute plea time of corresponding instance in the active instance list.
In this step, specifically the last-minute plea time can be updated using current time, such as uses current server The time at end updates the last-minute plea time of corresponding instance in the active instance list.
In the specific implementation, maintenance periodically can also be updated to the active instance list, detailed process is:
Inspect periodically the last time renewal time of each example in the active instance list;
If the last time renewal time of a certain example and the difference of current time exceed the threshold value of setting, the reality is judged Example is inactive example, and the example is deleted from the active instance list;
For example, can set a threshold to 12 hours, if checking, one of example last time renewal time is 2 Before it, set threshold value is exceeded, has then judged the example for inactive example, then just by the example from active instance list Middle deletion, the validity of active instance list can be thus always maintained at, reduce the caching pressure of server end.
And further can also be by the caching for the example for existing in the buffer but being not present in the active instance list Data are deleted, with ensure to be safeguarded it is data cached be all it is useful, very low data cached of utilization rate is emptied, to save About memory consumption.
For example, if having said 100 examples, wherein it is active always there are 20 examples, such as it is kept on all The monitor client moment checks current monitor data, and 80 examples are inactive in addition, for example two days log in a monitor client, Check five minutes every time, if not abnormal just exit monitoring system.In such a scenario, server end is only needed to 20 work The example that jumps provides data buffer storage, and 80 examples can not provide caching completely in addition, which reduces memory cost and Cpu occupancy, while the enquiry frequency of other 80 is very low, and the pressure of database can also be ignored substantially.
The operation of above steps by server end or can be integrated in the device in server end to complete.
Based on the method for the above-mentioned more instance datas of caching, the embodiment of the present invention additionally provides a kind of more instance datas of caching Device, be illustrated in figure 2 the structural representation of described device, described device includes:
Active instance list management unit, for safeguarding active instance list, comprised at least in the active instance list Field:Example id and example last time request server end data time T;
Data receipt unit, the request of data sent for receiving a certain example;
Instance data processing unit, the data that a certain example for being received according to the data receipt unit is sent please Ask and carry out lookup processing in the active instance list, specifically include:If do not find this in the active instance list Example, then the id of the example is added in the active instance list, and corresponding time T is set to current server end Time, and return to client corresponding to the example after inquiring about from database the data of the example;If in the active instance The example has been found in list, then the data cached of the example has been returned into client corresponding to the example, and described in renewal The last-minute plea time of corresponding instance in active instance list.
In the specific implementation, described device may also include:
Data cached administrative unit, for inquiring about the data of the example from database in the instance data processing unit And after returning to client corresponding to the example, the data of the example inquired from database are put into caching.
Above-mentioned active instance list management unit further can be also used for periodically carrying out more the active instance list New to safeguard, specifically, active instance list management unit can include updating maintenance module, described active for inspecting periodically The last time renewal time of each example in example list;If the last time renewal time of a certain example and the difference of current time Value then judges the example for inactive example, and the example is deleted from the active instance list more than the threshold value of setting;
Updating maintenance module can be also used for:To in the buffer exist but be not present in the active instance list The data cached deletion of example.
The specific work process of said apparatus is as described in above-mentioned embodiment of the method.
In summary, methods described of the embodiment of the present invention can either avoid the not high data cached committed memory of utilization rate empty Between, because the example quantity that needs update when renewal caches every time is few;Also cpu expense and unnecessary can be reduced as far as possible Database connects, and reduces the pressure of database.
The foregoing is only a preferred embodiment of the present invention, but protection scope of the present invention be not limited thereto, Any one skilled in the art is in the technical scope of present disclosure, the change or replacement that can readily occur in, It should all be included within the scope of the present invention.Therefore, protection scope of the present invention should be with the protection model of claims Enclose and be defined.

Claims (8)

  1. A kind of 1. method for caching more instance datas, it is characterised in that safeguard there are active instance row in the internal memory of server end Table, field is comprised at least in the active instance list:Example id and example last time request server end data time T;
    Methods described includes:
    , will if not finding the example in the active instance list when receiving the request of data that a certain example is sent The id of the example is added in the active instance list, and corresponding time T is set to the time at current server end, and from Client corresponding to the example is returned to after the data of the example are inquired about in database;And will exist in the buffer, but described The data cached deletion for the example being not present in active instance list;
    If having found the example in the active instance list, data cached example that returns to of the example is corresponded to Client, and update the last-minute plea time of corresponding instance in the active instance list.
  2. 2. the method for more instance datas is cached according to claim 1, it is characterised in that described that the reality is inquired about from database After returning to client corresponding to the example after the data of example, methods described also includes:
    The data of the example inquired from database are put into caching.
  3. 3. the method for more instance datas is cached according to claim 1, it is characterised in that methods described also includes:
    Maintenance periodically is updated to the active instance list.
  4. 4. the method for more instance datas is cached according to claim 3, it is characterised in that described periodically to the active instance List is updated maintenance:
    Inspect periodically the last time renewal time of each example in the active instance list;
    If the last time renewal time of a certain example and the difference of current time exceed the threshold value of setting, judge that the example is Inactive example, and the example is deleted from the active instance list.
  5. 5. a kind of device for caching more instance datas, it is characterised in that described device includes:
    Active instance list management unit, for safeguarding active instance list, field is comprised at least in the active instance list: Example id and example last time request server end data time T;
    Data receipt unit, the request of data sent for receiving a certain example;
    Instance data processing unit, the request of data that a certain example for being received according to the data receipt unit is sent exist Lookup processing is carried out in the active instance list, is specifically included:If not finding the example in the active instance list, Then the id of the example is added in the active instance list, and corresponding time T is set to the time at current server end, And return to client corresponding to the example after the data of the example are inquired about from database;And will exist in the buffer, but The data cached deletion for the example being not present in the active instance list;If found in the active instance list The example, then the data cached of the example is returned into client corresponding to the example, and updated in the active instance list The last-minute plea time of corresponding instance.
  6. 6. the device of more instance datas is cached as claimed in claim 5, it is characterised in that described device also includes:
    Data cached administrative unit, for inquiring about the data of the example from database in the instance data processing unit and returning After client corresponding to the example, the data of the example inquired from database are put into caching.
  7. 7. the device of more instance datas is cached as claimed in claim 5, it is characterised in that
    The active instance list management unit is further used for periodically being updated maintenance to the active instance list.
  8. 8. the device of more instance datas is cached as claimed in claim 7, it is characterised in that the active instance list management unit Further comprise:
    Updating maintenance module, for inspecting periodically the last time renewal time of each example in the active instance list;If certain The last time renewal time of one example and the difference of current time exceed the threshold value of setting, then judge the example for inactive reality Example, and the example is deleted from the active instance list.
CN201410648574.XA 2014-11-14 2014-11-14 A kind of method and device for caching more instance datas Active CN104331492B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410648574.XA CN104331492B (en) 2014-11-14 2014-11-14 A kind of method and device for caching more instance datas

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410648574.XA CN104331492B (en) 2014-11-14 2014-11-14 A kind of method and device for caching more instance datas

Publications (2)

Publication Number Publication Date
CN104331492A CN104331492A (en) 2015-02-04
CN104331492B true CN104331492B (en) 2017-11-21

Family

ID=52406219

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410648574.XA Active CN104331492B (en) 2014-11-14 2014-11-14 A kind of method and device for caching more instance datas

Country Status (1)

Country Link
CN (1) CN104331492B (en)

Families Citing this family (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106547751B (en) * 2015-09-16 2020-11-24 阿里巴巴集团控股有限公司 Cache data updating method and device
CN105468795A (en) * 2015-10-30 2016-04-06 广西慧云信息技术有限公司 Sensing device real-time data management method
CN106933933B (en) * 2015-12-31 2019-12-10 北京国双科技有限公司 Data table information processing method and device
CN105812189B (en) * 2016-04-26 2019-06-28 努比亚技术有限公司 A kind of information processing method and server
CN109120692B (en) * 2018-08-16 2021-09-28 北京百度网讯科技有限公司 Method and apparatus for processing requests
CN109255001A (en) * 2018-08-31 2019-01-22 阿里巴巴集团控股有限公司 Maintaining method and device, the electronic equipment in interface instance library
CN109213604B (en) * 2018-10-15 2021-08-20 北京奇艺世纪科技有限公司 Data source management method and device
CN110162543A (en) * 2019-05-29 2019-08-23 北京奇艺世纪科技有限公司 A kind of information query method and device
CN110795457B (en) * 2019-09-24 2023-05-05 苏宁云计算有限公司 Data caching processing method, device, computer equipment and storage medium
CN113688338A (en) * 2020-05-19 2021-11-23 上海惠芽信息技术有限公司 User data processing method, processing device and computer storage medium
CN111782185B (en) * 2020-06-30 2024-01-09 北京百度网讯科技有限公司 Management method, equipment and medium of artificial intelligent development platform
CN112433875B (en) * 2020-11-23 2024-07-16 京东科技控股股份有限公司 Middleware-based database operation method and device and terminal equipment
CN114385663B (en) * 2022-03-23 2022-06-28 北京国联政信科技有限公司 Method and apparatus for data processing

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1659548A (en) * 2002-07-17 2005-08-24 欧里科国际公司 System and method for caching data for a mobile application
CN102663096A (en) * 2012-04-11 2012-09-12 北京像素软件科技股份有限公司 Method for reading data based on data cache technology
CN102999444A (en) * 2012-11-13 2013-03-27 华为技术有限公司 Method and device for replacing data in caching module

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9298719B2 (en) * 2012-09-04 2016-03-29 International Business Machines Corporation On-demand caching in a WAN separated distributed file system or clustered file system cache

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1659548A (en) * 2002-07-17 2005-08-24 欧里科国际公司 System and method for caching data for a mobile application
CN102663096A (en) * 2012-04-11 2012-09-12 北京像素软件科技股份有限公司 Method for reading data based on data cache technology
CN102999444A (en) * 2012-11-13 2013-03-27 华为技术有限公司 Method and device for replacing data in caching module

Also Published As

Publication number Publication date
CN104331492A (en) 2015-02-04

Similar Documents

Publication Publication Date Title
CN104331492B (en) A kind of method and device for caching more instance datas
US20210044662A1 (en) Server side data cache system
CN112260876B (en) Dynamic gateway route configuration method, platform, computer equipment and storage medium
CN104765661B (en) The multinode hot spare method of Metadata Service node in a kind of cloud storage service
CN107092437A (en) Data write-in, read method and device, cloud storage system
CN101557427A (en) Method for providing diffluent information and realizing the diffluence of clients, system and server thereof
CN104537013B (en) A kind of method and apparatus of processing data
CN103729247B (en) Data acquisition request processing method and system and server
US20100262687A1 (en) Dynamic data partitioning for hot spot active data and other data
US20170269848A1 (en) Selecting pages implementing leaf nodes and internal nodes of a data set index for reuse
CN105653198A (en) Data processing method and device
CN111291083B (en) Web page source code data processing method, device and computer equipment
CN105554121A (en) Method and system for realizing load equalization of distributed cache system
CN105245560A (en) Method, device and system for realizing distributed cache
CN106777085A (en) A kind of data processing method, device and data query system
CN105635196A (en) Method and system of file data obtaining, and application server
CN103645904A (en) Cache realization method of interface calling
US20130060810A1 (en) Smart database caching
CN104580432A (en) Memcached system, memory cache data provision method and device, memory cache data maintenance method and device as well as cluster maintenance method and device
CN101404649B (en) A data processing system and method based on CACHE
CN102929943B (en) data output method and device
CN103561060A (en) Communication link method under multi-thread environment and transit server
CN105607606B (en) A kind of data acquisition device and method based on double mainboard frameworks
CN109597724B (en) Service stability measuring method, device, computer equipment and storage medium
CN105162837A (en) Method and system for improving I/O throughput rate in massive data storage environment

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CP02 Change in the address of a patent holder
CP02 Change in the address of a patent holder

Address after: 100083 No. 401, 4th Floor, Haitai Building, 229 North Fourth Ring Road, Haidian District, Beijing

Patentee after: BEIJING GRIDSUM TECHNOLOGY Co.,Ltd.

Address before: 100086 Cuigong Hotel, 76 Zhichun Road, Shuangyushu District, Haidian District, Beijing

Patentee before: BEIJING GRIDSUM TECHNOLOGY Co.,Ltd.

PE01 Entry into force of the registration of the contract for pledge of patent right
PE01 Entry into force of the registration of the contract for pledge of patent right

Denomination of invention: Method and device for caching multi-instance data

Effective date of registration: 20190531

Granted publication date: 20171121

Pledgee: Shenzhen Black Horse World Investment Consulting Co.,Ltd.

Pledgor: BEIJING GRIDSUM TECHNOLOGY Co.,Ltd.

Registration number: 2019990000503

PP01 Preservation of patent right
PP01 Preservation of patent right

Effective date of registration: 20240604

Granted publication date: 20171121