JP2012043338A - Cache management apparatus, cache management program and recording medium - Google Patents

Cache management apparatus, cache management program and recording medium Download PDF

Info

Publication number
JP2012043338A
JP2012043338A JP2010186031A JP2010186031A JP2012043338A JP 2012043338 A JP2012043338 A JP 2012043338A JP 2010186031 A JP2010186031 A JP 2010186031A JP 2010186031 A JP2010186031 A JP 2010186031A JP 2012043338 A JP2012043338 A JP 2012043338A
Authority
JP
Japan
Prior art keywords
cache
data
database
record
change history
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.)
Granted
Application number
JP2010186031A
Other languages
Japanese (ja)
Other versions
JP5385874B2 (en
Inventor
Shinji Fukatsu
真二 深津
Kyotaro Horiguchi
恭太郎 堀口
Kiyoshi Tanaka
清 田中
Motoyuki Horii
統之 堀井
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.)
Nippon Telegraph and Telephone Corp
Original Assignee
Nippon Telegraph and Telephone Corp
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 Nippon Telegraph and Telephone Corp filed Critical Nippon Telegraph and Telephone Corp
Priority to JP2010186031A priority Critical patent/JP5385874B2/en
Publication of JP2012043338A publication Critical patent/JP2012043338A/en
Application granted granted Critical
Publication of JP5385874B2 publication Critical patent/JP5385874B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

PROBLEM TO BE SOLVED: To reduce inconsistency between a database and a cache.SOLUTION: A cache management apparatus stores data IDs and registration date in a database management table 400, and also stores search queries and a search result ID list having data IDs of data included in cache data and generation date of the cache data to a cache management table 500. The apparatus searches for a record corresponding to a search query in the cache management table 500 and acquires a search result ID and the generation date of cache data at the time of search, and searches for a record having a data ID matching each of data IDs in the search result ID list from the database management table 400. The apparatus determines that the cache data corresponding to the search query is valid when the records for all the data IDs in the search result ID list are present in the database management table 400 and the registration dates of all the records are older than the generation date of the cache data.

Description

本発明は、データベースの検索結果をキャッシュとして保存し利用する検索システムにおいて、データベースとキャッシュの不整合を軽減する技術に関する。   The present invention relates to a technique for reducing inconsistencies between a database and a cache in a search system that stores and uses database search results as a cache.

検索システムにおいては、リクエストに応じてデータベースを検索し、その検索結果をレスポンスとして返却する。この際、同様のリクエストがあった場合、その都度、データベースを検索することはレスポンス時間やサーバ負荷を増大することとなる。そこで、リクエストに対するレスポンスをキャッシュデータとしてメモリなどの高速な記憶装置に蓄えておき、同様のリクエストがあった場合、レスポンス時間の短縮やサーバ負荷の軽減を実現している。   In the search system, the database is searched in response to the request, and the search result is returned as a response. At this time, if there is a similar request, searching the database each time increases the response time and server load. Accordingly, responses to requests are stored as cache data in a high-speed storage device such as a memory, and when there is a similar request, response time is shortened and server load is reduced.

"RFC 2616, Hypertext Transfer Protocol - HTTP/1.1: Caching in HTTP", [online],[平成22年8月9日検索]、インターネット〈URL:http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html〉"RFC 2616, Hypertext Transfer Protocol-HTTP / 1.1: Caching in HTTP", [online], [searched on August 9, 2010], Internet <URL: http://www.w3.org/Protocols/rfc2616/ rfc2616-sec13.html>

検索結果をキャッシュとして保存する場合、データベースとの整合性を保つことが重要となる。つまり、データベースに変更(データの追加/削除/更新)があり、キャッシュに含まれる情報と最新のデータベース内の情報に不整合が生じると、ある検索クエリに対する最新の検索結果とキャッシュとして保存した検索結果が異なるという問題が生じる。   When storing search results as a cache, it is important to maintain consistency with the database. In other words, if there is a change in the database (data addition / deletion / update) and the information contained in the cache is inconsistent with the information in the latest database, the latest search result for a search query and the search saved in the cache The problem is that the results are different.

そこで、一般的には、各キャッシュデータに有効期限を設定することで十分に新鮮であるもののみをキャッシュとして用いる形にしたり、定期的にキャッシュとデータベースとの差分をチェックすることで対処している。しかしながら、前者の方法では、有効期限の設定によっては不整合が大きくなり、後者は全キャッシュをチェックするため、キャッシュ更新に要する処理が大きくなるという問題がある。   Therefore, in general, by setting an expiration date for each cache data, only the one that is sufficiently fresh can be used as a cache, or the difference between the cache and the database can be checked periodically. Yes. However, the former method has a problem that the inconsistency becomes large depending on the setting of the expiration date, and the latter checks all caches, so that processing required for cache update becomes large.

また、データベースへの変更に応じてキャッシュを更新する方法も考えられるが、検索クエリに対応する検索結果をキャッシュとして保存する場合、あるデータが複数の異なる検索結果のキャッシュに含まれることがある。そのため、あるデータが更新/削除された場合、そのデータが含まれるキャッシュを全て探し出して無効化する必要が生じる。また、データが追加/更新された場合、そのデータが関連するキャッシュを探すためには、検索クエリとデータを内容レベル(例えば、検索クエリで指定されたキーワードとデータ内容に含まれるテキスト情報)で照合する必要が生じ、全キャッシュに対してこのような処理を行うことは処理量が非常に大きくなり、非効率である。   Although a method of updating the cache according to a change to the database is also conceivable, when a search result corresponding to a search query is stored as a cache, certain data may be included in a cache of a plurality of different search results. Therefore, when certain data is updated / deleted, it is necessary to search and invalidate all caches including the data. In addition, when data is added / updated, the search query and the data are searched at the content level (for example, the keyword specified in the search query and the text information included in the data content) in order to find the cache associated with the data. It is necessary to collate, and performing such processing for all caches is very inefficient and inefficient.

他にも、データベースへの変更に応じ、保持するキャッシュを全削除する方法も考えられるが、データベースの更新頻度、キャッシュの生成頻度によっては、処理のみが増え、キャッシュが有効的に利用されなくなり、無駄が多く、非効率なキャッシュ管理となる。   In addition, depending on the changes to the database, it is possible to delete all the caches that are held, but depending on the database update frequency and cache generation frequency, only the processing increases and the cache is not used effectively. This is wasteful and inefficient cache management.

本発明は、上記に鑑みてなされたものであり、キャッシュを用いた検索システムにおいて、データベースへの変更に伴うデータベースとキャッシュとの不整合を軽減し、かつ、キャッシュを効率的に管理することを実現することを目的とする。   The present invention has been made in view of the above, and in a search system using a cache, the inconsistency between the database and the cache due to the change to the database is reduced, and the cache is efficiently managed. It aims to be realized.

第1の本発明に係るキャッシュ管理装置は、データベースに格納されたデータを検索クエリを用いて検索した検索結果をキャッシュデータとしてキャッシュに格納するキャッシュ管理装置であって、前記データベースに格納されたデータを一意に識別するデータID、当該データの登録日時を関連付けたデータレコードを蓄積するデータベース管理テーブルと、前記キャッシュに格納されたキャッシュデータを一意に識別するキャッシュID、当該キャッシュデータに対応する検索クエリ、当該キャッシュデータに含まれるデータのデータIDを記載した検索結果リスト、当該キャッシュデータの生成日時を関連付けたキャッシュレコードを蓄積するキャッシュ管理テーブルと、検索クエリを受信したときに、当該検索クエリに一致する検索クエリを持つ前記キャッシュレコードを前記キャッシュ管理テーブルから検索し、検索したキャッシュレコードから前記検索結果リストと前記生成日時を取得する取得手段と、前記取得手段が取得した前記検索結果リストに記載されたデータIDそれぞれについて一致するデータIDを持つ前記データレコードを前記データベース管理テーブルから検索し、前記検索結果リストに記載されたデータIDのすべてについて、一致するデータIDを持つ前記データレコードが検索されるとともに検索されたデータレコードの前記登録日時が前記生成日時よりも古い場合は、前記取得手段が検索した前記キャッシュレコードに対応する前記キュッシュデータは有効であると判定し、それ以外の場合は当該キャッシュデータは無効であると判定する判定手段と、前記判定手段が前記キャッシュデータは有効であると判定した場合は、当該キャッシュデータを検索結果として返却し、受信した検索クエリに一致する検索クエリを持つ前記キャッシュレコードが検索できない場合、及び前記判定手段が前記キャッシュデータは無効であると判定した場合は、受信した検索クエリを用いて前記データベースを検索して検索結果を返却し、当該検索結果を前記キャッシュにキャッシュデータとして格納するとともに、前記キャッシュ管理テーブルに当該キャッシュデータのキャッシュID、検索に用いた検索クエリ、当該キャッシュデータに含まれるデータのデータIDを記載した検索結果リスト、当該キャッシュデータの生成日時を関連付けたキャッシュレコードを追加する検索手段と、を有することを特徴とする。   A cache management device according to a first aspect of the present invention is a cache management device for storing a search result obtained by searching data stored in a database using a search query as cache data in the cache, wherein the data stored in the database A data ID that uniquely identifies the data, a database management table that accumulates data records associated with the registration date and time of the data, a cache ID that uniquely identifies the cache data stored in the cache, and a search query corresponding to the cache data , A search result list that describes the data ID of the data included in the cache data, a cache management table that stores a cache record that associates the generation date and time of the cache data, and matches the search query when the search query is received Search to The cache record having an error is searched from the cache management table, the search result list and the generation date and time are acquired from the searched cache record, and the data described in the search result list acquired by the acquisition unit The data record having the matching data ID for each ID is searched from the database management table, and the data record having the matching data ID is searched and searched for all the data IDs described in the search result list. If the registered date and time of the data record is older than the generation date and time, the acquisition unit determines that the cache data corresponding to the cache record searched is valid, otherwise the cache data is Judgment that it is invalid And when the determination unit determines that the cache data is valid, the cache data is returned as a search result, and the cache record having a search query that matches the received search query cannot be searched; and When the determination unit determines that the cache data is invalid, the search unit is searched using the received search query, the search result is returned, and the search result is stored as cache data in the cache. The cache management table adds a cache ID of the cache data, a search query used for the search, a search result list describing the data ID of the data included in the cache data, and a cache record that associates the generation date and time of the cache data. And a search means. And features.

第2の本発明に係るキャッシュ管理装置は、データベースに格納されたデータを検索クエリを用いて検索した検索結果をキャッシュデータとしてキャッシュに格納するキャッシュ管理装置であって、前記データベースに格納されたデータを一意に識別するデータID、当該データに対する操作内容を示す管理フラグを関連付けた変更履歴を蓄積する変更履歴蓄積手段と、前記キャッシュに格納されたキャッシュデータを一意に識別するキャッシュID、当該キャッシュデータに対応する検索クエリ、当該キャッシュデータに含まれるデータのデータIDを記載した検索結果リスト、当該キャッシュデータの生成日時を関連付けたキャッシュレコードを蓄積するキャッシュ管理テーブルと、検索クエリを受信したときに、当該検索クエリに一致する検索クエリを持つ前記キャッシュレコードを前記キャッシュ管理テーブルから検索し、検索したキャッシュレコードから前記検索結果リストと前記生成日時を取得する取得手段と、前記取得手段が取得した前記検索結果リストに記載されたデータIDと一致するデータIDを持つ前記変更履歴を前記変更履歴蓄積手段から検索し、該当する変更履歴が検索されない場合及び検索された前記変更履歴すべての管理フラグがデータの追加を示している場合は、前記取得手段が検索した前記キャッシュレコードに対応する前記キュッシュデータは有効であると判定し、それ以外の場合は当該キャッシュデータは無効であると判定する判定手段と、前記判定手段が前記キャッシュデータは有効であると判定した場合は、当該キャッシュデータを検索結果として返却し、受信した検索クエリに一致する検索クエリを持つ前記キャッシュレコードが検索できない場合、及び前記判定手段が前記キャッシュデータは無効であると判定した場合は、受信した検索クエリを用いて前記データベースを検索して検索結果を返却し、当該検索結果を前記キャッシュにキャッシュデータとして格納するとともに、前記キャッシュ管理テーブルに当該キャッシュデータのキャッシュID、検索に用いた検索クエリ、当該キャッシュデータに含まれるデータのデータIDを記載した検索結果リスト、当該キャッシュデータの生成日時を関連付けたキャッシュレコードを追加する検索手段と、を有することを特徴とする。   A cache management device according to a second aspect of the present invention is a cache management device for storing a search result obtained by searching data stored in a database using a search query as cache data in the cache, wherein the data stored in the database A data ID that uniquely identifies the change history, a change history accumulation unit that accumulates a change history associated with a management flag indicating the operation content of the data, a cache ID that uniquely identifies the cache data stored in the cache, and the cache data When a search query is received, a search result list that describes the data ID of data included in the cache data, a cache management table that stores a cache record that associates the generation date and time of the cache data, and a search query Matches the search query The cache management table is searched for from the cache management table, the search result list and the generation date and time are acquired from the searched cache record, and the search result list acquired by the acquisition unit is described. When the change history having the data ID that matches the retrieved data ID is searched from the change history storage means, the corresponding change history is not searched, and the management flag of all the searched change history indicates addition of data In the case, it is determined that the cache data corresponding to the cache record searched by the acquisition unit is valid, and in other cases, the determination unit determines that the cache data is invalid, and the determination unit includes the determination unit If it is determined that the cache data is valid, the cache data is detected. As a result, when the cache record having a search query that matches the received search query cannot be searched, and when the determination unit determines that the cache data is invalid, the received search query is used to Search the database, return the search results, store the search results as cache data in the cache, and include the cache ID of the cache data, the search query used for the search, and the cache data in the cache management table A search result list in which the data ID of the data is described; and a search means for adding a cache record associated with the generation date and time of the cache data.

上記第2の本発明に係るキャッシュ管理装置において、前記データベースにデータが追加されたときは、前記変更履歴蓄積手段に変更履歴を追加して当該変更履歴に前記データID、データの追加を示す管理フラグを登録し、前記データベースのデータが変更あるいは削除されたときは、変更あるいは削除されたデータのデータIDを有する変更履歴を前記変更履歴蓄積手段から検索し、該当する変更履歴がない場合及び管理フラグがデータの追加を示す変更履歴のみが検索された場合は、前記変更履歴蓄積手段に変更履歴を追加して当該変更履歴に前記データID、データの変更あるいは削除を示す管理フラグを登録し、管理フラグがデータの変更あるいは削除を示す変更履歴が検索された場合は、当該変更履歴の管理フラグを更新する変更履歴管理手段を有することを特徴とする。   In the cache management device according to the second aspect of the present invention, when data is added to the database, the change history is added to the change history accumulating means, and the data ID and data added to the change history are managed. When a flag is registered and the data in the database is changed or deleted, the change history having the data ID of the changed or deleted data is retrieved from the change history storage means, and there is no corresponding change history and management When only the change history indicating that the flag indicates the addition of data is searched, the change history is added to the change history accumulating means, and the data ID, the management flag indicating the change or deletion of the data is registered in the change history, When a change history is retrieved in which the management flag indicates data change or deletion, the change flag for updating the change history management flag is updated. Characterized in that it has a history management means.

上記第2の本発明に係るキャッシュ管理装置において、前記変更履歴蓄積手段から各変更履歴の管理フラグを取得し、当該管理フラグがデータの追加を示している場合はデータが追加された件数をカウントし、それ以外の場合はその変更履歴のデータIDを削除対象リストに追加し、前記変更履歴蓄積手段から全変更履歴を削除する変更履歴更新手段と、前記件数に基づいて算出した不整合の程度が所定の閾値を超えた場合、前記キャッシュ管理テーブルの全キャッシュレコード及び前記キャッシュの格納された全キャッシュデータを削除し、前記件数に基づいて算出した不整合の程度が所定の閾値を超えない場合、前記削除対象リストに記載されているデータIDを有する前記キャッシュレコードを前記キャッシュ管理テーブルから削除するとともに、当該キャッシュレコードに対応するキャッシュデータを前記キャッシュから削除するキャッシュ削除手段を有することを特徴とする。   In the cache management device according to the second aspect of the present invention, the management flag of each change history is acquired from the change history storage means, and when the management flag indicates the addition of data, the number of added data is counted Otherwise, the change history data means for adding the data ID of the change history to the deletion target list and deleting the entire change history from the change history storage means, and the degree of inconsistency calculated based on the number of cases When all the cache records in the cache management table and all the cache data stored in the cache are deleted and the degree of inconsistency calculated based on the number of cases does not exceed the predetermined threshold And deleting the cache record having the data ID described in the deletion target list from the cache management table. Together, and having a cache deletion means for deleting the cache data corresponding to the cache records from the cache.

上記第1、第2の本発明に係るキャッシュ管理装置において、前記データベースにデータが追加された件数をカウントし、当該件数に基づいて算出した不整合の程度が所定の閾値を超えた場合、前記キャッシュ管理テーブルの全キャッシュレコード及び前記キャッシュの格納された全キャッシュデータを削除するとともに、前記件数をクリアするキャッシュ削除手段を有することを特徴とする。   In the cache management device according to the first and second aspects of the present invention, when the number of data added to the database is counted and the degree of inconsistency calculated based on the number of cases exceeds a predetermined threshold, In addition to deleting all cache records in the cache management table and all cache data stored in the cache, the cache management means includes a cache deleting means for clearing the number of cases.

上記第1、第2の本発明に係るキャッシュ管理装置において、前記判定手段は、前記生成日時と現在日時を比較し、前記生成日時が現在日時から所定の期間内である場合は、前記取得手段が検索した前記キャッシュレコードに対応する前記キャッシュデータは有効であると判定することを特徴する。   In the cache management device according to the first and second aspects of the present invention, the determination unit compares the generation date and time with the current date and time, and if the generation date and time is within a predetermined period from the current date and time, the acquisition unit The cache data corresponding to the cache record retrieved by is determined to be valid.

第3の本発明に係るキャッシュ管理プログラムは、上記キャッシュ管理装置を構成する各手段としてコンピュータを機能させることを特徴とする。   According to a third aspect of the present invention, there is provided a cache management program for causing a computer to function as each means constituting the cache management apparatus.

第4の本発明に係る記録媒体は、上記キャッシュ管理プログラムを記録したことを特徴とする。   A recording medium according to a fourth aspect of the present invention records the above cache management program.

本発明によれば、キャッシュを用いた検索システムにおいて、データベースへの変更に伴うデータベースとキャッシュとの不整合を軽減し、かつ、キャッシュを効率的に管理することを実現することができる。   According to the present invention, in a search system using a cache, it is possible to reduce inconsistencies between the database and the cache due to changes to the database, and to efficiently manage the cache.

第1の実施の形態におけるキャッシュ管理装置を含む検索システムの構成を示すブロック図である。It is a block diagram which shows the structure of the search system containing the cache management apparatus in 1st Embodiment. データベース管理テーブルの保持する情報の例を示す図である。It is a figure which shows the example of the information which a database management table hold | maintains. キャッシュ管理テーブルの保持する情報の例を示す図である。It is a figure which shows the example of the information which a cache management table hold | maintains. 第1の実施の形態におけるデータベース変更時の処理の流れを示すフローチャートである。It is a flowchart which shows the flow of the process at the time of the database change in 1st Embodiment. 第1の実施の形態における検索時の処理の流れを示すフローチャートである。It is a flowchart which shows the flow of the process at the time of the search in 1st Embodiment. 第1の実施の形態における有効期限切れキャッシュデータを削除する処理の流れを示すフローチャートである。It is a flowchart which shows the flow of the process which deletes the expiration date cache data in 1st Embodiment. 第2の実施の形態におけるキャッシュ管理装置を含む検索システムの構成を示すブロック図である。It is a block diagram which shows the structure of the search system containing the cache management apparatus in 2nd Embodiment. データベース変更履歴の保持する情報の例を示す図である。It is a figure which shows the example of the information which a database change log | history hold | maintains. 第2の実施の形態におけるデータベース変更時の処理の流れを示すフローチャートである。It is a flowchart which shows the flow of the process at the time of the database change in 2nd Embodiment. 第2の実施の形態における検索時の処理の流れを示すフローチャートである。It is a flowchart which shows the flow of the process at the time of the search in 2nd Embodiment. 第2の実施の形態におけるキャッシュデータを削除する処理の流れを示すフローチャートである。It is a flowchart which shows the flow of the process which deletes the cache data in 2nd Embodiment. 第2の実施の形態におけるキャッシュデータを削除する別の処理の流れを示すフローチャートである。It is a flowchart which shows the flow of another process which deletes the cache data in 2nd Embodiment. 第3の実施の形態におけるデータベースにデータを追加したときの処理の流れを示すフローチャートである。It is a flowchart which shows the flow of a process when data are added to the database in 3rd Embodiment. 第4の実施の形態におけるキャッシュデータの有効性確認に無効期間を設けた場合の検索時の処理の流れを示すフローチャートである。It is a flowchart which shows the flow of the process at the time of a search when the invalidity period is provided in the validity check of the cache data in 4th Embodiment.

以下、本発明の実施の形態について図面を用いて説明する。   Hereinafter, embodiments of the present invention will be described with reference to the drawings.

[第1の実施の形態]
図1は、第1の実施の形態におけるキャッシュ管理装置を含む検索システムの構成を示すブロック図である。同図に示す検索システムは、データ登録処理部100、検索処理部200、キャッシュ管理部300、データベース管理テーブル400、データベース410、キャッシュ管理テーブル500、およびキャッシュ510を備える。検索システムが備える各部は、演算処理装置、記憶装置等を備えたコンピュータにより構成して、各部の処理がプログラムによって実行されるものとしてもよい。このプログラムは検索システムが備える記憶装置に記憶されており、磁気ディスク、光ディスク、半導体メモリ等の記録媒体に記録することも、ネットワークを通して提供することも可能である。以下、各部について説明する。
[First Embodiment]
FIG. 1 is a block diagram showing a configuration of a search system including a cache management device according to the first embodiment. The search system shown in the figure includes a data registration processing unit 100, a search processing unit 200, a cache management unit 300, a database management table 400, a database 410, a cache management table 500, and a cache 510. Each unit included in the search system may be configured by a computer including an arithmetic processing device, a storage device, and the like, and the processing of each unit may be executed by a program. This program is stored in a storage device included in the search system, and can be recorded on a recording medium such as a magnetic disk, an optical disk, or a semiconductor memory, or provided through a network. Hereinafter, each part will be described.

データ登録処理部100は、データベース410への登録要求を受信し、データベース410への変更(データの追加/更新/削除)処理を行うとともに、データベース410への変更内容をデータベース管理テーブル400に登録する。   The data registration processing unit 100 receives a registration request to the database 410, performs a change process (addition / update / deletion of data) to the database 410, and registers the change contents to the database 410 in the database management table 400. .

検索処理部200は、検索クエリの受信、検索結果の返却といった検索処理を行う。   The search processing unit 200 performs a search process such as receiving a search query and returning a search result.

キャッシュ管理部300は、キャッシュ510が保持するキャッシュデータの管理・削除を行うとともに、検索時にキャッシュの有効性を確認する。   The cache management unit 300 manages and deletes cache data held in the cache 510 and confirms the validity of the cache at the time of retrieval.

データベース管理テーブル400は、データベース410に格納されたデータの情報を管理する。図2に、データベース管理テーブル400の保持する情報の例を示す。同図に示すように、データベース管理テーブル400の各レコードは、データベース410に格納されたデータを一意に識別するデータID、データ自体を格納するデータ内容、およびデータベースへの変更が発生した日時を示す登録日時で構成される。   The database management table 400 manages information on data stored in the database 410. FIG. 2 shows an example of information held in the database management table 400. As shown in the figure, each record of the database management table 400 indicates a data ID for uniquely identifying data stored in the database 410, data contents for storing the data itself, and date and time when a change to the database has occurred. Consists of registration date and time.

キャッシュ管理テーブル500は、キャッシュ510に保存されたキャッシュデータの情報を管理する。図3に、キャッシュ管理テーブル500の保持する情報の例を示す。同図に示すように、キャッシュ管理テーブル500の各レコードは、キャッシュ510が保持するキャッシュデータを一意に識別するキャッシュID、キャッシュデータに対応する検索クエリ、キャッシュデータに含まれるデータのデータIDが記載された検索結果IDリスト、およびキャッシュデータを生成した日時を示す生成日時で構成される。なお、キャッシュIDは、後述する検索時の処理において、受信した検索クエリとキャッシュ管理テーブル500の検索クエリとの照合を高速に行うため、検索クエリの文字列から生成するハッシュ値を用いるとよい。また、キャッシュ510においては、検索クエリに対する検索結果をキャッシュデータとして保管するが、そのキャッシュデータをキャッシュIDに対応する形で保管するとよい。例えば、図3の項番c1のキャッシュデータは、"cache_000010010" というファイル名とする。   The cache management table 500 manages information on cache data stored in the cache 510. FIG. 3 shows an example of information held in the cache management table 500. As shown in the figure, each record of the cache management table 500 describes a cache ID that uniquely identifies cache data held by the cache 510, a search query corresponding to the cache data, and a data ID of data included in the cache data. And a generation date / time indicating the date / time when the cache data is generated. Note that the cache ID may be a hash value generated from a character string of the search query so that the received search query and the search query of the cache management table 500 can be collated at high speed in the search processing described later. In the cache 510, the search result for the search query is stored as cache data. The cache data may be stored in a form corresponding to the cache ID. For example, the cache data of item number c1 in FIG. 3 has a file name “cache_000010010”.

次に、データベース変更時の処理について説明する。図4は、データベース変更時の処理の流れを示すフローチャートである。   Next, processing when changing the database will be described. FIG. 4 is a flowchart showing the flow of processing when changing the database.

まず、データ登録処理部100がデータベース410への登録要求を受信すると、その登録要求をデータベース410に送信するとともに、その登録要求がデータの追加/更新であるか、データの削除であるかを判定する(ステップS101)。   First, when the data registration processing unit 100 receives a registration request to the database 410, it transmits the registration request to the database 410 and determines whether the registration request is data addition / update or data deletion. (Step S101).

登録要求が追加/更新の場合、データ登録処理部100は、データベース管理テーブル400から登録要求のデータに該当するレコードを検索し(ステップS102)、該当レコードの有無を判定する(ステップS103)。該当するレコードは、データベース410に格納されたデータを一意に識別するデータIDをキーに検索する。   When the registration request is addition / update, the data registration processing unit 100 searches the database management table 400 for a record corresponding to the registration request data (step S102), and determines whether there is a corresponding record (step S103). The corresponding record is searched using the data ID uniquely identifying the data stored in the database 410 as a key.

該当レコードが無い場合は、データベース管理テーブル400にレコードを追加し(ステップS104)、そのレコードにデータベース410に追加した内容(データID、データ内容、登録日時)を登録する(ステップS105)。   If there is no corresponding record, a record is added to the database management table 400 (step S104), and the contents (data ID, data contents, registration date and time) added to the database 410 are registered in the record (step S105).

該当レコードが有る場合は、そのレコードをデータベース410を更新した内容(データ内容、登録日時)で更新する。   If there is a corresponding record, the record is updated with the updated contents of the database 410 (data contents, registration date and time).

一方、登録要求が「削除」の場合は、データベース管理テーブル400から登録要求のデータに該当するレコードを検索し(ステップS107)、そのレコードを削除する(ステップS108)。   On the other hand, if the registration request is “delete”, a record corresponding to the data of the registration request is searched from the database management table 400 (step S107), and the record is deleted (step S108).

次に、検索時の処理について説明する。図5は、検索時の処理の流れを示すフローチャートである。   Next, processing during search will be described. FIG. 5 is a flowchart showing the flow of processing during a search.

まず、検索処理部200が検索クエリを受信すると、キャッシュ管理部300は、受信した検索クエリとキャッシュ管理テーブル500の検索クエリを照合し(ステップS201)、該当するレコードが有るか否か判定する(ステップS202)。このとき、キャッシュIDを検索クエリの文字列から生成したハッシュ値としている場合、受信した検索クエリをハッシュ値に変換し、キャッシュIDと照合してもよい。   First, when the search processing unit 200 receives a search query, the cache management unit 300 collates the received search query with the search query in the cache management table 500 (step S201), and determines whether or not there is a corresponding record (step S201). Step S202). At this time, when the cache ID is a hash value generated from the character string of the search query, the received search query may be converted into a hash value and collated with the cache ID.

検索クエリを照合した結果、キャッシュ管理テーブル500に該当レコードがある場合、当該レコードからキャッシュデータの生成日時を取得し(ステップS203)、当該レコードが示すキャッシュデータが有効期限内か否か確認する(ステップS204)。キャッシュデータの有効期限は運用に応じて設定されるものとし、例えば生成日時から1ヶ月を有効期限として設定する。   As a result of collating the search query, if there is a corresponding record in the cache management table 500, the generation date and time of the cache data is acquired from the record (step S203), and it is confirmed whether or not the cache data indicated by the record is within the expiration date ( Step S204). The expiration date of the cache data is set according to the operation. For example, one month from the generation date is set as the expiration date.

キャッシュデータが有効期限切れの場合、受信した検索クエリに対応するキャッシュデータを「無効」と判断し(ステップS213)、キャッシュ管理テーブル500から当該レコードを削除するとともに、当該レコードが示すキャッシュデータをキャッシュ510から削除する(ステップS214)。そして、ステップS221へ進み受信した検索クエリでデータベースを検索する。   If the cache data has expired, the cache data corresponding to the received search query is determined to be “invalid” (step S213), the record is deleted from the cache management table 500, and the cache data indicated by the record is stored in the cache 510. (Step S214). In step S221, the database is searched using the received search query.

キャッシュデータが有効期限内の場合は、当該レコードから検索結果IDリストを取得する(ステップS205)。   If the cache data is within the expiration date, a search result ID list is acquired from the record (step S205).

そして、検索結果IDリストに記載されたデータIDをキーとして、各データIDに対応するデータベース管理テーブル400のレコードを検索し(ステップS206)、該当するレコードが有るか否か判定する(ステップS207)。   Then, using the data ID described in the search result ID list as a key, a record in the database management table 400 corresponding to each data ID is searched (step S206), and it is determined whether there is a corresponding record (step S207). .

データベース管理テーブル400に該当するレコードが無い場合、つまり、該当するデータがデータベース410から削除されていた場合、キャッシュが「無効」である場合の処理を行って(ステップS213,S214)、ステップS221へ進み受信した検索クエリでデータベースを検索する。   When there is no corresponding record in the database management table 400, that is, when the corresponding data has been deleted from the database 410, processing is performed when the cache is “invalid” (steps S213 and S214), and the process proceeds to step S221. Search the database with the received search query.

データベース管理テーブル400に該当するレコードがある場合、当該レコードの登録日時を取得し、ステップS203で取得した生成日時と照合し(ステップS208)、キャッシュデータの生成日時がデータの登録日時以前であるか否か判定する(ステップS209)。   If there is a corresponding record in the database management table 400, the registration date / time of the record is acquired, checked against the generation date / time acquired in step S203 (step S208), and whether the generation date / time of the cache data is before the data registration date / time. It is determined whether or not (step S209).

キャッシュデータの生成日時がデータの登録日時以前の場合、つまり、キャッシュデータの生成後にデータが更新されている場合、キャッシュが「無効」である場合の処理を行って(ステップS213,S214)、ステップS221へ進みデータベースへの検索処理を行う。   When the generation date and time of the cache data is before the data registration date and time, that is, when the data is updated after the generation of the cache data, processing is performed when the cache is "invalid" (steps S213 and S214), and step Proceeding to S221, a database search process is performed.

キャッシュデータの生成日時がデータの登録日時以降の場合、つまり、キャッシュデータの生成後に該当するデータが更新されていない場合、検索結果IDリストに記載されたデータIDすべてについて処理を行ったか否か判定し(ステップS210)、まだ処理していないデータIDが存在する場合はステップS206に戻り、検索結果IDリストに記載された全てのデータIDに対して上記ステップS206〜S209の処理を繰り返す。   When the generation date and time of the cache data is after the registration date and time of the data, that is, when the corresponding data has not been updated after the generation of the cache data, it is determined whether or not all the data IDs listed in the search result ID list have been processed If there is a data ID that has not been processed yet (step S210), the process returns to step S206, and the processes of steps S206 to S209 are repeated for all the data IDs described in the search result ID list.

検索結果IDリストに記載された全てのデータIDがそれぞれ示すデータが、受信した検索クエリに対応するキャッシュデータの生成後に更新/削除されていない場合、つまり、検索結果IDリストに記載されたすべてのデータIDについて該当するデータレコードが存在し、そのデータレコードすべての登録日時が生成日時よりも古い場合、そのキャッシュデータを「有効」と判断し(ステップS211)、検索結果としてそのキャッシュデータを返却する(ステップS212)。   When the data indicated by all the data IDs described in the search result ID list has not been updated / deleted after the generation of the cache data corresponding to the received search query, that is, all the data described in the search result ID list If a corresponding data record exists for the data ID and the registration date / time of all the data records is older than the generation date / time, the cache data is determined to be “valid” (step S211), and the cache data is returned as a search result. (Step S212).

一方、受信した検索クエリに対応するキャッシュデータが無い場合、あるいは受信した検索クエリに対応するキャッシュデータが無効の場合は、受信した検索クエリでデータベース410を検索する(ステップS221)。そして、キャッシュ管理テーブル500にレコードを追加し、追加したレコードにキャッシュデータの情報、検索結果の情報(キャッシュID、検索クエリ、検索結果IDリスト、生成日時)を登録するとともに(ステップS222)、取得した検索結果をキャッシュデータとしてキャッシュ510に保存する(ステップS223)。そして、検索結果を返却する(ステップS224)。   On the other hand, if there is no cache data corresponding to the received search query, or if the cache data corresponding to the received search query is invalid, the database 410 is searched with the received search query (step S221). Then, a record is added to the cache management table 500, and cache data information and search result information (cache ID, search query, search result ID list, generation date and time) are registered in the added record (step S222) and acquired. The retrieved result is stored as cache data in the cache 510 (step S223). Then, the search result is returned (step S224).

次に、有効期限切れキャッシュデータを削除する処理について説明する。図6は、有効期限切れキャッシュデータを削除する処理の流れを示すフローチャートである。本処理は、運用に応じた設定に従って定期的(例えば、一週間毎)に実施されるものとする。   Next, processing for deleting expired cache data will be described. FIG. 6 is a flowchart showing the flow of processing for deleting expired cache data. This processing is performed periodically (for example, every week) according to the setting according to the operation.

まず、キャッシュ管理部300は、キャッシュ管理テーブル500の各レコードの生成日時を取得し(ステップS301)、当該レコードが示すキャッシュデータが有効期限内か否か確認する(ステップS302)。キャッシュの有効期限は前述したように運用に応じて設定されるものである。   First, the cache management unit 300 acquires the generation date and time of each record in the cache management table 500 (step S301), and checks whether the cache data indicated by the record is within the expiration date (step S302). The cache expiration date is set according to the operation as described above.

有効期限の確認の結果、キャッシュデータが有効期限切れであった場合、キャッシュ管理テーブル500から当該レコードを削除するとともに、該当するキャッシュデータをキャッシュ510から削除する(ステップS303)。   As a result of checking the expiration date, if the cache data has expired, the record is deleted from the cache management table 500 and the corresponding cache data is deleted from the cache 510 (step S303).

キャッシュ管理テーブル500の有する全てのレコードに対して処理を行ったか否か判定し(ステップS304)、全レコードに対して上記ステップS301〜S303の処理を繰り返す。   It is determined whether or not the processing has been performed for all the records included in the cache management table 500 (step S304), and the processing of steps S301 to S303 is repeated for all the records.

以上説明したように、本実施の形態によれば、データベース管理テーブル400に、データベース410へ登録したデータを一意に識別するデータID、およびデータを追加/更新した登録日時を格納するとともに、キャッシュ管理テーブル500に、キャッシュデータ生成時の検索クエリ、キャッシュデータに含まれるデータのデータIDを有する検索結果IDリスト、およびキュッシュデータを生成した日時を示す生成日時を格納しておき、検索時に、検索クエリと合致する検索クエリを有するレコードをキャッシュ管理テーブル500から検索し、検索されたレコードから検索結果IDリストと生成日時を取得し、検索結果IDリストに記載されたデータIDそれぞれについて一致するデータIDを持つレコードをデータベース管理テーブル400から検索し、検索結果IDリストに記載されたデータIDを有するレコードがデータベース管理テーブル400に存在しない場合、あるいは、検索されたレコードの登録日時がキャッシュデータの生成日時よりも新しい場合は、検索クエリに対応するキャッシュデータは無効であると判断し、検索結果IDリストに記載されたデータIDのすべてについて、一致するデータIDを有するレコードがデータベース管理テーブル400に存在し、そのレコードすべての登録日時がキャッシュデータの生成日時よりも古い場合は、検索クエリに対応するキャッシュデータは有効であると判断することにより、データベース410からデータを削除すること、並びに、データベース410のデータを更新することで生じるデータベース410とキャッシュ510との不整合を無くすことができる。   As described above, according to the present embodiment, the database management table 400 stores the data ID for uniquely identifying the data registered in the database 410 and the registration date and time when the data is added / updated, as well as the cache management. The table 500 stores a search query at the time of cache data generation, a search result ID list having a data ID of data included in the cache data, and a generation date and time indicating the date and time when the cache data is generated. Are searched from the cache management table 500, the search result ID list and the generation date and time are obtained from the searched records, and the data ID that matches each data ID described in the search result ID list is obtained. Records that have When the record having the data ID described in the search result ID list does not exist in the database management table 400, or when the registration date and time of the retrieved record is newer than the generation date and time of the cache data, It is determined that the cache data corresponding to the search query is invalid, and records having matching data IDs exist in the database management table 400 for all of the data IDs listed in the search result ID list, and all the records are registered. If the date and time is older than the generation date and time of the cache data, it is determined that the cache data corresponding to the search query is valid, and the data is deleted from the database 410 and the data in the database 410 is updated. Resulting database 4 0 and it is possible to eliminate the mismatch between a cache 510.

本実施の形態によれば、検索時にその検索クエリに対応するキャッシュデータのみ有効性を判断するので、キャッシュデータの有効性を判断する処理コストを抑えることができ、効率的なキャッシュ管理が可能となる。   According to the present embodiment, the validity of only the cache data corresponding to the search query is determined at the time of the search, so that the processing cost for determining the validity of the cache data can be suppressed, and efficient cache management can be performed. Become.

[第2の実施の形態]
第1の実施の形態では、キャッシュ管理テーブル500のレコードが保持する検索結果IDリストに記載された各データIDが示すデータに更新/削除の操作があったか否かをデータベース管理テーブル400に照会することでキャッシュデータの有効性を判断した(図5のステップS206〜S209)。この際、データベース管理テーブル400の保持するレコード数が多くなれば照会に要する時間も長くなり、検索結果の応答時間を増加させることになる。
[Second Embodiment]
In the first embodiment, the database management table 400 is inquired as to whether or not the data indicated by each data ID stored in the search result ID list held by the record of the cache management table 500 has been updated / deleted. Thus, the validity of the cache data is determined (steps S206 to S209 in FIG. 5). At this time, if the number of records held in the database management table 400 increases, the time required for the inquiry also increases, and the response time of the search result increases.

そこで、第2の実施の形態では、ある期間内に実施されたデータベースへの変更内容を管理し、キャッシュ管理テーブル500の検索結果IDリストに記載された各データIDとデータベースへの変更内容を照合し、キャッシュデータ生成後にそのキャッシュデータに関連するデータに変更があったか否か判定し、キャッシュデータの有効性を確認する。   Therefore, in the second embodiment, the contents of changes to the database executed within a certain period are managed, and each data ID described in the search result ID list of the cache management table 500 is collated with the contents of change to the database. Then, after the cache data is generated, it is determined whether or not the data related to the cache data has changed, and the validity of the cache data is confirmed.

図7は、第2の実施の形態におけるキャッシュ管理装置を含む検索システムの構成を示すブロック図である。同図に示す検索システムは、図1に示したものに対してデータベース変更履歴600を追加したものである。   FIG. 7 is a block diagram illustrating a configuration of a search system including a cache management device according to the second embodiment. The search system shown in the figure is obtained by adding a database change history 600 to that shown in FIG.

データベース変更履歴600は、データベース410への変更情報を管理する。図8に、データベース変更履歴600の保持する情報の例を示す。同図に示すように、データベース変更履歴600の各レコードは、データベース410への変更が発生した登録日時、データベース410に格納されたデータを一意に識別するデータID、およびデータベース410への変更内容を表す管理フラグで構成される。管理フラグは、データの追加/更新/削除をそれぞれ”0”,”1”,”2”で表す。データベース変更履歴600は、キャッシュ管理テーブル500の検索結果IDリストとの照合処理を高速に実施できるようにメモリで保持するとよい。   The database change history 600 manages change information for the database 410. FIG. 8 shows an example of information held in the database change history 600. As shown in the figure, each record of the database change history 600 includes a registration date and time when a change to the database 410 has occurred, a data ID for uniquely identifying data stored in the database 410, and the contents of the change to the database 410. Consists of management flags to represent. The management flag represents data addition / update / deletion as “0”, “1”, and “2”, respectively. The database change history 600 may be held in a memory so that the matching process with the search result ID list of the cache management table 500 can be performed at high speed.

次に、データベース変更時の処理について説明する。図9は、データベース変更時の処理の流れを示すフローチャートである。図9のステップS601〜S608のデータベース管理テーブル400にレコードを追加/更新/削除する処理は図4のステップS101〜S108と同様であるのでここでの説明は省略する。以下、本実施の形態の拡張部分である、データベース変更履歴600に関する処理について説明する。   Next, processing when changing the database will be described. FIG. 9 is a flowchart showing the flow of processing when changing the database. The processing for adding / updating / deleting records to / from the database management table 400 in steps S601 to S608 in FIG. 9 is the same as steps S101 to S108 in FIG. Hereinafter, processing related to the database change history 600, which is an extended portion of the present embodiment, will be described.

データベース410にデータが追加されたときは、データベース管理テーブル400にレコードが追加される(ステップS604,S605)。そして、データ登録処理部100は、データベース変更履歴600にレコードを追加し(ステップS611)、追加したレコードに履歴情報(登録日時、データID、管理フラグ”0”)を登録する(ステップS612)。なお、管理フラグの”0”は、データが追加されたことを表す。   When data is added to the database 410, a record is added to the database management table 400 (steps S604 and S605). Then, the data registration processing unit 100 adds a record to the database change history 600 (step S611), and registers history information (registration date, data ID, management flag “0”) in the added record (step S612). The management flag “0” indicates that data has been added.

データベース410のデータが更新されたときは、データベース管理テーブル400のレコードを更新する(ステップS606)。そして、データ登録処理部100は、更新したデータのIDを有する履歴情報をデータベース変更履歴600から検索し(ステップS621)、その履歴情報の管理フラグを確認する(ステップS622)。管理フラグが”1”か”2”の場合、つまり、その履歴情報がデータの更新/削除を示す場合は、当該レコードの登録日時と管理フラグ(”1”を記載)を更新して処理を終了する(ステップS626)。管理フラグが”0”の場合、つまり、その履歴情報がデータの追加を示す場合は、全履歴情報を処理したか否か判定し(ステップS623)、まだ処理していない履歴情報がある場合はステップS621に戻り処理を繰り返す。上記の処理の結果、更新したデータのデータIDを有する履歴情報に管理フラグが”1”または”2”のものが無い場合は、データベース変更履歴600にレコードを追加し(ステップS624)、追加したレコードに履歴情報(登録日時、データID、管理フラグ”1”)を登録する(ステップS625)。   When the data in the database 410 is updated, the record in the database management table 400 is updated (step S606). The data registration processing unit 100 searches the database change history 600 for history information having the updated data ID (step S621), and checks the management flag of the history information (step S622). If the management flag is “1” or “2”, that is, if the history information indicates update / deletion of data, the registration date and time of the record and the management flag (described as “1”) are updated. The process ends (step S626). If the management flag is “0”, that is, if the history information indicates the addition of data, it is determined whether or not all history information has been processed (step S623), and if there is history information that has not yet been processed. Returning to step S621, the process is repeated. As a result of the above processing, when there is no history information having the data ID of the updated data having a management flag of “1” or “2”, a record is added to the database change history 600 (step S624) and added. History information (registration date, data ID, management flag “1”) is registered in the record (step S625).

データベース410のデータが削除されたときは、データベース管理テーブル400のレコードを削除する(ステップS608)。そして、データ登録処理部100は、削除したデータのIDを有する履歴情報をデータベース変更履歴600から検索し(ステップS631)、その履歴情報の管理フラグを確認する(ステップS632)。管理フラグが”1”か”2”の場合、つまり、その履歴情報がデータの更新/削除を示す場合は、当該レコードの登録日時と管理フラグ(”2”を記載)を更新して処理を終了する(ステップS636)。管理フラグが”0”の場合、つまり、その履歴情報がデータの追加を示す場合は、全履歴情報を処理したか否か判定し(ステップS623)、まだ処理していない履歴情報がある場合はステップS621に戻り処理を繰り返す。上記の処理の結果、削除したデータのデータIDを有する履歴情報に管理フラグが”1”または”2”のものが無い場合は、データベース変更履歴600にレコードを追加し(ステップS634)、追加したレコードに履歴情報(登録日時、データID、管理フラグ”2”)を登録する(ステップS635)。   When the data in the database 410 is deleted, the record in the database management table 400 is deleted (step S608). Then, the data registration processing unit 100 searches the database change history 600 for history information having the deleted data ID (step S631), and confirms the management flag of the history information (step S632). If the management flag is “1” or “2”, that is, if the history information indicates update / deletion of data, the registration date and time of the record and the management flag (described as “2”) are updated. The process ends (step S636). If the management flag is “0”, that is, if the history information indicates the addition of data, it is determined whether or not all history information has been processed (step S623), and if there is history information that has not yet been processed. Returning to step S621, the process is repeated. As a result of the above processing, when there is no history information having the data ID of the deleted data having the management flag “1” or “2”, a record is added to the database change history 600 (step S634). History information (registration date, data ID, management flag “2”) is registered in the record (step S635).

このように、データベース変更履歴600は、データベースへのデータの追加履歴とデータの変更/削除履歴を別々に管理する。また、データの変更/削除履歴に関しては、履歴情報を最新の情報に上書きすることで、データベースへの変更が頻繁に発生した場合でもデータベース変更履歴600のサイズを抑えることができ、あるキャッシュデータに関連するデータの変更/削除の履歴を照合する処理を高速に実施することが可能となる。   As described above, the database change history 600 separately manages the data addition history and the data change / deletion history to the database. In addition, regarding the data change / deletion history, the history information is overwritten with the latest information, so that the size of the database change history 600 can be suppressed even when frequent changes to the database occur, and certain cache data can be stored. It is possible to perform a process of collating the history of changing / deleting related data at high speed.

次に、検索時の処理について説明する。図10は、検索時の処理の流れを示すフローチャートである。同図に示す検索時の処理は、第1の実施の形態における検索時の処理(図5参照)と比べると、データベース管理テーブル400を利用する代わりに、データベース変更履歴600を利用する点で異なる。具体的には、図5のステップS206〜S209と、図10のステップS706〜S708が相違する部分である。   Next, processing during search will be described. FIG. 10 is a flowchart showing the flow of processing during a search. The processing at the time of searching shown in the figure differs from the processing at the time of searching (see FIG. 5) in the first embodiment in that a database change history 600 is used instead of using the database management table 400. . Specifically, steps S206 to S209 in FIG. 5 are different from steps S706 to S708 in FIG.

検索処理部200が検索クエリを受信すると、キャッシュ管理部300は、受信した検索クエリとキャッシュ管理テーブル500の検索クエリを照合し(ステップS701)、該当するレコードが有るか否か判定する(ステップS702)。該当するレコードが無い場合は、受信した検索クエリでデータベース410を検索し、検索結果をキャッシュデータとして保存し、検索結果を返却する(ステップS721〜S724)。   When the search processing unit 200 receives the search query, the cache management unit 300 collates the received search query with the search query in the cache management table 500 (step S701), and determines whether there is a corresponding record (step S702). ). If there is no corresponding record, the database 410 is searched with the received search query, the search result is stored as cache data, and the search result is returned (steps S721 to S724).

キャッシュ管理テーブル500に該当するレコードが有る場合は、当該レコードからキャッシュデータの生成日時を取得し(ステップS703)、当該レコードが示すキャッシュデータが有効期限内か否か確認する(ステップS704)。キャッシュデータが有効期限切れの場合は、受信した検索クエリに対応するキャッシュデータを「無効」と判断し(ステップS712)、キャッシュ管理テーブル500から当該レコードを削除するとともに、当該レコードが示すキャッシュデータをキャッシュ510から削除する(ステップS713)。そして、ステップS721へ進み受信した検索クエリでデータベースを検索する。   If there is a record corresponding to the cache management table 500, the generation date and time of the cache data is acquired from the record (step S703), and it is confirmed whether or not the cache data indicated by the record is within the expiration date (step S704). If the cache data has expired, the cache data corresponding to the received search query is determined to be “invalid” (step S712), the record is deleted from the cache management table 500, and the cache data indicated by the record is cached. Delete from 510 (step S713). In step S721, the database is searched using the received search query.

キャッシュデータが有効期限内の場合は、当該レコードから検索結果IDリストを取得する(ステップS705)。   If the cache data is within the expiration date, a search result ID list is acquired from the record (step S705).

そして、検索結果IDリストに記載されたデータIDをキーとして、各データIDを含む履歴情報をデータベース変更履歴600から検索し(ステップS706)、履歴情報が存在するか否か判定する(ステップS707)。   Then, using the data ID described in the search result ID list as a key, history information including each data ID is searched from the database change history 600 (step S706), and it is determined whether the history information exists (step S707). .

データベース変更履歴600に履歴情報が存在する場合、検索された履歴情報の中に管理フラグか”1”または”2”のものが存在するか否か判定する(ステップS708)。データベース変更履歴600は、1つのデータIDに対して管理フラグが異なる履歴情報が複数記載される場合があるので、ステップS706では、複数の履歴情報が検索されることがある。このステップS708の処理では、それら複数の履歴情報に対して処理を実施する。   If history information exists in the database change history 600, it is determined whether or not the retrieved history information includes a management flag “1” or “2” (step S708). Since a plurality of pieces of history information having different management flags may be described for one data ID in the database change history 600, a plurality of pieces of history information may be searched in step S706. In the process of step S708, the process is performed on the plurality of history information.

検索された履歴情報の中に管理フラグが”1”または”2”の履歴情報がある場合、つまり、ある期間内に該当するデータが更新または削除されていた場合、キャッシュが「無効」である場合の処理を行って(ステップS712〜S713)、ステップS721へ進み受信した検索クエリでデータベースを検索する。   If there is history information whose management flag is "1" or "2" in the retrieved history information, that is, if the corresponding data has been updated or deleted within a certain period, the cache is "invalid" The process is performed (steps S712 to S713), and the process proceeds to step S721 to search the database with the received search query.

一方、データベース変更履歴600に履歴情報が存在しない場合、つまり、ある期間内に該当するデータの追加/変更/削除が無かった場合、及び、検索された履歴情報の中に管理フラグが”1”または”2”のものが存在しない場合、つまり、ある期間内に該当するデータは追加のみであった場合、検索結果IDリストに記載されたデータIDすべてについて処理を行ったか否か判定し(ステップS709)、まだ処理していないデータIDが存在する場合はステップS706に戻り、検索結果IDリストに記載された全てのデータIDに対して上記ステップS706〜S708の処理を繰り返す。   On the other hand, when there is no history information in the database change history 600, that is, when there is no addition / change / deletion of the corresponding data within a certain period, and the management flag is “1” in the retrieved history information. Alternatively, if there is no data “2”, that is, if the corresponding data is only added within a certain period, it is determined whether or not all data IDs listed in the search result ID list have been processed (step S709) If there is a data ID that has not yet been processed, the process returns to step S706, and the processes of steps S706 to S708 are repeated for all the data IDs listed in the search result ID list.

そして、検索結果IDリストに記載された全データIDに対して処理した結果、データベース変更履歴600に検索結果IDリストに記載されたデータIDに関係する履歴情報が無いか、あるいは、関係する履歴情報はあるが管理フラグが”1”または”2”の履歴情報が無い場合、つまり、ある期間内に、受信した検索クエリに対応するキャッシュデータに関係する全データが更新も、削除もされていなかった場合、そのキャッシュデータを「有効」と判断し(ステップS710)、検索結果としてそのキャッシュデータを返却する(ステップS711)。   As a result of processing for all data IDs listed in the search result ID list, there is no history information related to the data IDs listed in the search result ID list in the database change history 600, or related history information If there is no history information with management flag “1” or “2”, that is, all data related to the cache data corresponding to the received search query has not been updated or deleted within a certain period. If so, the cache data is determined to be “valid” (step S710), and the cache data is returned as a search result (step S711).

次に、キャッシュデータを削除する処理について説明する。図11は、キャッシュデータを削除する処理の流れを示すフローチャートである。本処理は、運用に応じた設定に従って定期的(例えば、一日毎)に実施されるものとする。   Next, processing for deleting cache data will be described. FIG. 11 is a flowchart showing the flow of processing for deleting cache data. This processing is assumed to be performed periodically (for example, every day) according to settings according to operation.

まず、キャッシュ管理部300は、データベース変更履歴600の履歴情報毎にデータIDと管理フラグを取得し(ステップS801)、管理フラグの値を判定する(ステップS802)。   First, the cache management unit 300 acquires a data ID and a management flag for each history information of the database change history 600 (step S801), and determines the value of the management flag (step S802).

管理フラグが”0”の場合、キャッシュ管理部300で管理する追加件数をカウントする(ステップS803)。   When the management flag is “0”, the number of additional cases managed by the cache management unit 300 is counted (step S803).

管理フラグが”1”または”2”の場合、キャッシュ管理部300で管理するキャッシュ削除対象IDリストに当該データIDを追加し(ステップS804)、データベース変更履歴600から当該履歴情報を削除する(ステップS805)。   When the management flag is “1” or “2”, the data ID is added to the cache deletion target ID list managed by the cache management unit 300 (step S804), and the history information is deleted from the database change history 600 (step S804). S805).

そして、データベース変更履歴600の全ての履歴情報について処理したか否か判定し(ステップS806)、全ての履歴情報についてステップS801〜S805を繰り返す。   Then, it is determined whether or not all the history information of the database change history 600 has been processed (step S806), and steps S801 to S805 are repeated for all the history information.

データベース変更履歴600の全履歴情報の処理後、カウントされた追加件数をもとにデータベースとキャッシュとの不整合の程度を判定する(ステップS807)。不整合の程度を判定する方法としては、追加件数が所定の閾値を超えたか否かで判断する方法、総データ数に対する追加件数の比率が所定の閾値を超えたか否かで判断する方法が考えられる。他にも、データベース変更履歴600から登録日時を取得し、登録日時が予め定める閾値よりも古いか否かで判断する方法もある。   After processing all the history information of the database change history 600, the degree of inconsistency between the database and the cache is determined based on the counted number of added cases (step S807). As a method for determining the degree of inconsistency, there are a method for determining whether or not the number of additional records exceeds a predetermined threshold, and a method for determining whether or not the ratio of the number of additional records to the total number of data exceeds a predetermined threshold. It is done. In addition, there is a method of acquiring the registration date / time from the database change history 600 and determining whether the registration date / time is older than a predetermined threshold.

不整合の程度が所定の閾値を超えている場合、データベース変更履歴600の全履歴情報を削除し(ステップS808)、キャッシュ管理テーブル500の全レコード、並びに、キャッシュ510の保持する全キャッシュデータを削除する(ステップS809)。なお、追加件数はキャッシュデータを削除する処理のときに随時カウントするので、キャッシュ管理部300が永続的に管理する必要はない。   If the degree of inconsistency exceeds a predetermined threshold, all history information in the database change history 600 is deleted (step S808), and all records in the cache management table 500 and all cache data held in the cache 510 are deleted. (Step S809). Note that the number of additional cases is counted as needed during the process of deleting cache data, so the cache management unit 300 does not need to be managed permanently.

不整合の程度が所定の閾値を超えていない場合は、キャッシュ管理テーブル500の各レコードの検索結果IDリストを取得し(ステップS810)、ステップS804で作成したキャッシュ削除対象IDリストと取得した検索結果IDリストを照合する(ステップS811)。   If the degree of inconsistency does not exceed a predetermined threshold, a search result ID list of each record in the cache management table 500 is acquired (step S810), and the cache deletion target ID list created in step S804 and the acquired search result The ID list is collated (step S811).

照合の結果、一致するデータIDがある場合、つまり、ある期間内に該当するデータが更新、または、削除されていた場合、キャッシュ管理テーブル500の当該レコードが示す検索クエリに対応するキャッシュデータを「無効」と判断し、キャッシュ管理テーブル500の当該レコードを削除するとともに、該当するキャッシュデータをキャッシュ510から削除する(ステップS813)。   As a result of the collation, if there is a matching data ID, that is, if the corresponding data has been updated or deleted within a certain period, the cache data corresponding to the search query indicated by the record in the cache management table 500 is “ It is determined as “invalid”, the record in the cache management table 500 is deleted, and the corresponding cache data is deleted from the cache 510 (step S813).

そして、キャッシュ管理テーブル500の全レコードについて処理したか否か判定し(ステップS814)、キャッシュ管理テーブル500の全てのレコードについて上記ステップS810〜S813の処理を繰り返す。   Then, it is determined whether or not all the records of the cache management table 500 have been processed (step S814), and the processes of steps S810 to S813 are repeated for all the records of the cache management table 500.

このように、データベース変更履歴600では、データベース410へデータを追加した場合の履歴情報はその数が増加し、データベースとキャッシュとの不整合の程度が所定の閾値を超えるまで保持される。一方、データベース410のデータを変更/削除した場合の履歴情報は、上記キャッシュデータを削除する処理が実行されるときに削除されるので、データベース変更履歴600のサイズの増大を抑えることができ、データベース変更履歴600との照合処理を高速に実施することが可能となる。   As described above, in the database change history 600, the number of history information when data is added to the database 410 increases, and is retained until the degree of inconsistency between the database and the cache exceeds a predetermined threshold. On the other hand, since the history information when the data in the database 410 is changed / deleted is deleted when the process of deleting the cache data is executed, an increase in the size of the database change history 600 can be suppressed. The verification process with the change history 600 can be performed at high speed.

次に、上記のキャッシュデータを削除する処理において、キャッシュデータの有効期限切れ処理を追加した例について説明する。図12は、図11に示したフローチャートのステップS810〜S814の不整合の程度が閾値内であったときの処理に、キャッシュデータの有効期限切れ処理を追加したフローチャートである。他の処理は、図11と同様であるのでここでの説明は省略する。   Next, an example in which cache data expiration processing is added to the processing for deleting cache data will be described. FIG. 12 is a flowchart in which cache data expiration processing is added to the processing when the degree of inconsistency in steps S810 to S814 in the flowchart shown in FIG. 11 is within the threshold. The other processes are the same as those in FIG. 11 and will not be described here.

不整合の程度が所定の閾値を超えていない場合は、キャッシュ管理テーブル500の各レコードの検索結果IDリストに加えて生成日時を取得し(ステップS820)、当該レコードが示すキャッシュデータが有効期限内であるか否か判定する(ステップS821)。キャッシュデータの有効期限は、運用に応じて設定されるものとし、例えば、生成日時が1ヶ月以内の場合は有効期限内であると判定する。   If the degree of inconsistency does not exceed the predetermined threshold, in addition to the search result ID list of each record in the cache management table 500, the generation date and time is acquired (step S820), and the cache data indicated by the record is within the expiration date It is determined whether or not (step S821). The expiration date of the cache data is set according to the operation. For example, if the generation date is within one month, it is determined that the expiration date is within the expiration date.

キャッシュデータが有効期限切れであった場合は、キャッシュ管理テーブル500から当該レコードを削除するとともに、該当するキャッシュデータをキャッシュ510から削除する(ステップS824)。   If the cache data has expired, the record is deleted from the cache management table 500 and the corresponding cache data is deleted from the cache 510 (step S824).

キャッシュデータが有効期限内の場合は、キャッシュ削除対象IDリストと取得した検索結果IDリストを照合し(ステップS822)、一致するデータIDがあるか否か判定する(ステップS823)。一致するデータIDがある場合は、キャッシュ管理テーブル500から当該レコードを削除するとともに、該当するキャッシュデータをキャッシュ510から削除する(ステップS824)。   If the cache data is within the expiration date, the cache deletion target ID list and the acquired search result ID list are collated (step S822), and it is determined whether there is a matching data ID (step S823). If there is a matching data ID, the record is deleted from the cache management table 500 and the corresponding cache data is deleted from the cache 510 (step S824).

そして、キャッシュ管理テーブル500の全レコードについて処理したか否か判定し(ステップS825)、キャッシュ管理テーブル500の全てのレコードについて上記ステップS820〜S824の処理を繰り返す。   Then, it is determined whether or not all the records in the cache management table 500 have been processed (step S825), and the processes in steps S820 to S824 are repeated for all the records in the cache management table 500.

もちろん、有効期限切れのキャッシュデータの処理として図6の処理を用いるものでもよい。   Of course, the processing of FIG. 6 may be used as processing of expired cache data.

以上説明したように、本実施の形態によれば、データベース変更履歴600に、データベース410への変更が発生したデータのデータID、変更内容を表す管理フラグを格納しておき、検索時にキャッシュデータの有効性を判断するときに、検索クエリに対応するキャッシュデータの検索結果IDリストに記載されたデータIDが示すデータについて、データベース変更履歴600に変更/削除された履歴情報が存在する場合は、そのキャッシュデータは無効であると判断することにより、データベース管理テーブル400を参照する場合と比べて、処理コスト、処理時間を抑えることができる。   As described above, according to the present embodiment, the database change history 600 stores the data ID of the data that has changed to the database 410 and the management flag indicating the change contents, and the cache data is stored at the time of retrieval. When there is history information that has been changed / deleted in the database change history 600 for the data indicated by the data ID listed in the search result ID list of the cache data corresponding to the search query when determining the validity, By determining that the cache data is invalid, the processing cost and processing time can be reduced as compared with the case where the database management table 400 is referred to.

[第3の実施の形態]
第1の実施の形態を用いることで、データの更新、削除に伴うデータベースとキャッシュとの不整合を無くすことができる。しかしながら、データの追加に伴うデータベースとキャッシュとの不整合は、キャッシュデータの有効期限切れ、または、検索時のキャッシュ無効判断によるキャッシュデータの削除が実施され、その後、新たにキャッシュデータが生成されるまで解消されない。また、追加されたデータが関連するキャッシュデータを探す場合、検索クエリとデータを内容レベル(例えば、検索クエリで指定されたキーワードとデータ内容に含まれるテキスト情報)で照合する必要が生じ、全キャッシュデータに対してこのような処理を行うことは処理量が非常に大きくなり、非効率である。
[Third Embodiment]
By using the first embodiment, it is possible to eliminate inconsistency between the database and the cache due to data update and deletion. However, the inconsistency between the database and the cache due to the addition of data is due to the expiration of the cache data or until the cache data is deleted by the cache invalidity determination at the time of search, and then new cache data is generated It will not be resolved. In addition, when searching for cache data related to the added data, it is necessary to collate the search query and the data at the content level (for example, the keyword specified in the search query and the text information included in the data content). Performing such processing on data is very inefficient and inefficient.

そこで、第3の実施の形態では、データベース410へのデータ追加時に追加件数の累積をカウントし、その追加件数をもとにデータベースとキャッシュとの不整合の程度を判断し、不整合の程度が所定の閾値を超えた場合に、キャッシュ510が保持する全キャッシュデータを削除する。   Therefore, in the third embodiment, when the data is added to the database 410, the cumulative number of additional cases is counted, and the degree of inconsistency between the database and the cache is determined based on the number of additional cases, and the degree of inconsistency is determined. When the predetermined threshold is exceeded, all cache data held by the cache 510 is deleted.

図13は、データベース410にデータを追加したときの処理の流れを示すフローチャートであり、図4のステップS105以降に実施される。データの更新、削除の処理については図4に示す処理と同様である。   FIG. 13 is a flowchart showing the flow of processing when data is added to the database 410, and is executed after step S105 in FIG. The data update and deletion processes are the same as the processes shown in FIG.

データ登録処理部100は、データベース410にデータを登録した後、データベース管理テーブル400にレコードを追加し、そのレコードにデータベース410に追加した内容を登録する(図4のステップS104,S105)。   After registering data in the database 410, the data registration processing unit 100 adds a record to the database management table 400, and registers the added content in the database 410 in the record (steps S104 and S105 in FIG. 4).

その後、本実施の形態では、データ登録処理部100で管理する追加件数をカウントし(ステップS401)、不整合の程度を判定する(ステップS402)。不整合の程度を判定する方法としては、追加件数が所定の閾値を超えたか否かで判断する方法、あるいは、総データ数に対する追加件数の比率が所定の閾値を超えたか否かで判定する方法が考えられる。   Thereafter, in the present embodiment, the number of additional cases managed by the data registration processing unit 100 is counted (step S401), and the degree of inconsistency is determined (step S402). As a method for determining the degree of inconsistency, a method for determining whether or not the number of additional records exceeds a predetermined threshold, or a method for determining whether or not the ratio of the number of additional records to the total number of data exceeds a predetermined threshold Can be considered.

不整合の程度が所定の閾値を超えている場合、追加件数をクリアし(ステップS403)、キャッシュ管理テーブル500の全レコード、並びに、キャッシュ510が保持する全キャッシュデータを削除する(ステップS404)。   If the degree of inconsistency exceeds a predetermined threshold, the number of additional records is cleared (step S403), and all records in the cache management table 500 and all cache data held by the cache 510 are deleted (step S404).

また、データの追加によるデータベースとキャッシュの不整合を減らす方法として、データベースへの登録要求として「追加(キャッシュクリア)」を新たに設け、データ登録処理部100がその登録要求を受信した場合、データベースとキャッシュとの不整合の程度を判断することなく、キャッシュ管理テーブル500の全レコード、並びに、キャッシュ510が保持する全キャッシュデータを削除する方法も考えられる。   Further, as a method of reducing inconsistency between the database and the cache due to the addition of data, when “addition (cache clear)” is newly provided as a registration request to the database, and the data registration processing unit 100 receives the registration request, the database A method may be considered in which all records in the cache management table 500 and all cache data held by the cache 510 are deleted without determining the degree of inconsistency between the cache and the cache.

以上説明したように、本実施の形態によれば、データベース410へのデータの追加時に追加件数の累積をカウントし、その追加件数をもとにデータベースとキャッシュとの不整合の程度を判断し、不整合の程度が所定の閾値を超えた場合に全キャッシュデータを削除することにより、データの追加に伴うデータベースとキャッシュとの不整合についてもある程度軽減することができる。   As described above, according to the present embodiment, when the data is added to the database 410, the cumulative number of additional cases is counted, and the degree of inconsistency between the database and the cache is determined based on the additional number, By deleting all cache data when the degree of inconsistency exceeds a predetermined threshold, inconsistency between the database and the cache accompanying data addition can be reduced to some extent.

なお、本実施の形態におけるキャッシュデータの削除は、第2の実施の形態にも適用でき、その場合、キャッシュデータを削除するときに全履歴情報を削除する。   Note that the deletion of cache data in this embodiment can also be applied to the second embodiment. In this case, all history information is deleted when the cache data is deleted.

[第4の実施の形態]
第1の実施の形態では、検索時にキャッシュの無効/有効を判定することで、データベースとキャッシュデータの不整合を軽減している。その際、受信した検索クエリに対するキュッシュデータのみの有効性を判断することで、キャッシュチェックに要する処理コストの軽減を図っている。しかしながら、同じ検索クエリが頻繁に来る場合にもその都度キャッシュデータの確認を実施するため、処理が冗長である。
[Fourth Embodiment]
In the first embodiment, inconsistency between the database and the cache data is reduced by determining invalidity / validity of the cache at the time of retrieval. At that time, the processing cost required for the cache check is reduced by determining the validity of only the cache data for the received search query. However, since the cache data is checked each time the same search query comes frequently, the processing is redundant.

そこで、第4の実施の形態では、キャッシュデータの生成から一定期間内(例えば1時間)にそのキャッシュデータに対応する検索クエリを受信した場合、保持するキャッシュデータは十分に新鮮で有効性の確認処理は不要であるとみなし、当該キャッシュデータを検索結果として返却する。   Therefore, in the fourth embodiment, when a search query corresponding to the cache data is received within a certain period (for example, 1 hour) after the generation of the cache data, the cache data to be held is sufficiently fresh and the validity is confirmed. The processing is considered unnecessary, and the cache data is returned as a search result.

図14は、キャッシュデータの有効性確認に無効期間を設けた場合の検索時の処理の流れを示すフローチャートである。図14に示す処理は、図5,10に示す処理にキャッシュデータの生成日時から一定期間内であるか否か判断する処理を加えたものである。   FIG. 14 is a flowchart showing the flow of processing at the time of retrieval when an invalid period is provided for the validity check of cache data. The process shown in FIG. 14 is obtained by adding the process shown in FIGS. 5 and 10 to determine whether or not it is within a certain period from the generation date and time of the cache data.

検索処理部200が検索クエリを受信すると、キャッシュ管理部300は、受信した検索クエリとキャッシュ管理テーブル500の検索クエリを照合し(ステップS901)、該当するレコードが有るか否か判定する(ステップS902)。該当するレコードが無い場合は、受信した検索クエリでデータベース410を検索し、検索結果をキャッシュデータとして保存し、検索結果を返却する(ステップS908〜S911)。   When the search processing unit 200 receives the search query, the cache management unit 300 collates the received search query with the search query in the cache management table 500 (step S901), and determines whether there is a corresponding record (step S902). ). If there is no corresponding record, the database 410 is searched with the received search query, the search result is stored as cache data, and the search result is returned (steps S908 to S911).

該当するレコードが有る場合は、そのレコードからキャッシュデータの生成日時を取得する(ステップS903)。そして、生成日時と現在時刻を比較し(ステップS904)、現在時刻が生成日時から一定期間内であるか否か判定する(ステップS905)。   If there is a corresponding record, the generation date and time of the cache data is acquired from the record (step S903). Then, the generation date and time are compared with the current time (step S904), and it is determined whether the current time is within a certain period from the generation date and time (step S905).

現在時刻が生成日時から一定期間内である場合は、キャッシュデータは十分に新鮮で有効性の確認処理は不要と判断し、ステップS906のキャッシュデータの有効性確認の処理を実施せず、検索結果として当該キャッシュデータを返却する(ステップS907)。   If the current time is within a certain period from the generation date and time, it is determined that the cache data is sufficiently fresh and the validity check process is unnecessary, the cache data validity check process in step S906 is not performed, and the search result The cache data is returned as (step S907).

現在時刻が生成日時から一定期間以上離れている場合は、キャッシュデータの有効性を判定する(ステップS906)。キャッシュデータが有効の場合は、検索結果としてキャッシュデータを返却する(ステップS907)。キャッシュデータが無効の場合は、ステップS909へ進み受信した検索クエリでデータベースを検索する(ステップS908〜S911)。ステップS906のキャッシュデータの有効性の判定は、図5のステップS204〜S214、あるいは図10のステップS704〜S713の処理を用いる。   If the current time is more than a certain period away from the generation date and time, the validity of the cache data is determined (step S906). If the cache data is valid, the cache data is returned as a search result (step S907). If the cache data is invalid, the process advances to step S909 to search the database with the received search query (steps S908 to S911). The determination of the validity of the cache data in step S906 uses the processing in steps S204 to S214 in FIG. 5 or steps S704 to S713 in FIG.

以上説明したように、本実施の形態によれば、検索時にキャッシュ管理テーブル500からキャッシュデータの生成日時を取得し、現在時刻が生成日時から一定期間内である場合は、そのキャッシュデータは十分に新鮮で有効性の確認処理は不要であると判断することにより、同じ検索クエリを頻繁に受信する場合に、その検索クエリに対応するキャッシュデータの有効性判断をその都度行わなくて済み、キャッシュ管理にかかる総体的な処理コストを軽減することができる。   As described above, according to the present embodiment, the cache data generation date and time is acquired from the cache management table 500 at the time of retrieval, and if the current time is within a certain period from the generation date and time, the cache data is sufficient. By judging that the process of checking validity is not necessary, it is not necessary to determine the validity of cache data corresponding to the search query every time the same search query is frequently received. Can reduce the overall processing cost.

100…データ登録処理部
200…検索処理部
300…キャッシュ管理部
400…データベース管理テーブル
410…データベース
500…キャッシュ管理テーブル
510…キャッシュ
600…データベース変更履歴
DESCRIPTION OF SYMBOLS 100 ... Data registration process part 200 ... Search process part 300 ... Cache management part 400 ... Database management table 410 ... Database 500 ... Cache management table 510 ... Cache 600 ... Database change history

Claims (8)

データベースに格納されたデータを検索クエリを用いて検索した検索結果をキャッシュデータとしてキャッシュに格納するキャッシュ管理装置であって、
前記データベースに格納されたデータを一意に識別するデータID、当該データの登録日時を関連付けたデータレコードを蓄積するデータベース管理テーブルと、
前記キャッシュに格納されたキャッシュデータを一意に識別するキャッシュID、当該キャッシュデータに対応する検索クエリ、当該キャッシュデータに含まれるデータのデータIDを記載した検索結果リスト、当該キャッシュデータの生成日時を関連付けたキャッシュレコードを蓄積するキャッシュ管理テーブルと、
検索クエリを受信したときに、当該検索クエリに一致する検索クエリを持つ前記キャッシュレコードを前記キャッシュ管理テーブルから検索し、検索したキャッシュレコードから前記検索結果リストと前記生成日時を取得する取得手段と、
前記取得手段が取得した前記検索結果リストに記載されたデータIDそれぞれについて一致するデータIDを持つ前記データレコードを前記データベース管理テーブルから検索し、前記検索結果リストに記載されたデータIDのすべてについて、一致するデータIDを持つ前記データレコードが検索されるとともに検索されたデータレコードの前記登録日時が前記生成日時よりも古い場合は、前記取得手段が検索した前記キャッシュレコードに対応する前記キュッシュデータは有効であると判定し、それ以外の場合は当該キャッシュデータは無効であると判定する判定手段と、
前記判定手段が前記キャッシュデータは有効であると判定した場合は、当該キャッシュデータを検索結果として返却し、受信した検索クエリに一致する検索クエリを持つ前記キャッシュレコードが検索できない場合、及び前記判定手段が前記キャッシュデータは無効であると判定した場合は、受信した検索クエリを用いて前記データベースを検索して検索結果を返却し、当該検索結果を前記キャッシュにキャッシュデータとして格納するとともに、前記キャッシュ管理テーブルに当該キャッシュデータのキャッシュID、検索に用いた検索クエリ、当該キャッシュデータに含まれるデータのデータIDを記載した検索結果リスト、当該キャッシュデータの生成日時を関連付けたキャッシュレコードを追加する検索手段と、
を有することを特徴とするキャッシュ管理装置。
A cache management device that stores a search result obtained by searching data stored in a database using a search query as cache data in a cache,
A data ID for uniquely identifying data stored in the database, a database management table for accumulating data records associated with the registration date and time of the data, and
Associating a cache ID for uniquely identifying the cache data stored in the cache, a search query corresponding to the cache data, a search result list describing the data ID of the data included in the cache data, and the generation date and time of the cache data A cache management table for storing cached records,
When the search query is received, the cache record having the search query that matches the search query is searched from the cache management table, and the search result list and the generation date and time are acquired from the searched cache record;
The database management table is searched for the data record having a matching data ID for each data ID described in the search result list acquired by the acquisition means, and for all the data IDs described in the search result list, When the data record having the matching data ID is searched and the registration date / time of the searched data record is older than the generation date / time, the cache data corresponding to the cache record searched by the acquisition unit is valid. Determining means for determining that the cache data is invalid otherwise, and
When the determination unit determines that the cache data is valid, the cache data is returned as a search result, and the cache record having a search query that matches the received search query cannot be searched; and the determination unit If the cache data is determined to be invalid, the database is searched using the received search query, the search result is returned, the search result is stored as cache data in the cache, and the cache management Search means for adding a cache ID of the cache data, a search query used for the search, a search result list in which the data ID of the data included in the cache data is described, and a cache record associated with the generation date and time of the cache data; ,
A cache management apparatus comprising:
データベースに格納されたデータを検索クエリを用いて検索した検索結果をキャッシュデータとしてキャッシュに格納するキャッシュ管理装置であって、
前記データベースに格納されたデータを一意に識別するデータID、当該データに対する操作内容を示す管理フラグを関連付けた変更履歴を蓄積する変更履歴蓄積手段と、
前記キャッシュに格納されたキャッシュデータを一意に識別するキャッシュID、当該キャッシュデータに対応する検索クエリ、当該キャッシュデータに含まれるデータのデータIDを記載した検索結果リスト、当該キャッシュデータの生成日時を関連付けたキャッシュレコードを蓄積するキャッシュ管理テーブルと、
検索クエリを受信したときに、当該検索クエリに一致する検索クエリを持つ前記キャッシュレコードを前記キャッシュ管理テーブルから検索し、検索したキャッシュレコードから前記検索結果リストと前記生成日時を取得する取得手段と、
前記取得手段が取得した前記検索結果リストに記載されたデータIDと一致するデータIDを持つ前記変更履歴を前記変更履歴蓄積手段から検索し、該当する変更履歴が検索されない場合及び検索された前記変更履歴すべての管理フラグがデータの追加を示している場合は、前記取得手段が検索した前記キャッシュレコードに対応する前記キュッシュデータは有効であると判定し、それ以外の場合は当該キャッシュデータは無効であると判定する判定手段と、
前記判定手段が前記キャッシュデータは有効であると判定した場合は、当該キャッシュデータを検索結果として返却し、受信した検索クエリに一致する検索クエリを持つ前記キャッシュレコードが検索できない場合、及び前記判定手段が前記キャッシュデータは無効であると判定した場合は、受信した検索クエリを用いて前記データベースを検索して検索結果を返却し、当該検索結果を前記キャッシュにキャッシュデータとして格納するとともに、前記キャッシュ管理テーブルに当該キャッシュデータのキャッシュID、検索に用いた検索クエリ、当該キャッシュデータに含まれるデータのデータIDを記載した検索結果リスト、当該キャッシュデータの生成日時を関連付けたキャッシュレコードを追加する検索手段と、
を有することを特徴とするキャッシュ管理装置。
A cache management device that stores a search result obtained by searching data stored in a database using a search query as cache data in a cache,
A change history accumulating unit for accumulating a change history associated with a data ID for uniquely identifying data stored in the database and a management flag indicating an operation content for the data;
Associating a cache ID for uniquely identifying the cache data stored in the cache, a search query corresponding to the cache data, a search result list describing the data ID of the data included in the cache data, and the generation date and time of the cache data A cache management table for storing cached records,
When the search query is received, the cache record having the search query that matches the search query is searched from the cache management table, and the search result list and the generation date and time are acquired from the searched cache record;
When the change history having the data ID that matches the data ID described in the search result list acquired by the acquisition unit is searched from the change history storage unit, and the corresponding change history is not searched and the change that has been searched When all the management flags in the history indicate addition of data, it is determined that the cache data corresponding to the cache record searched by the acquisition unit is valid, and in other cases, the cache data is invalid. Determination means for determining that there is,
When the determination unit determines that the cache data is valid, the cache data is returned as a search result, and the cache record having a search query that matches the received search query cannot be searched; and the determination unit If the cache data is determined to be invalid, the database is searched using the received search query, the search result is returned, the search result is stored as cache data in the cache, and the cache management Search means for adding a cache ID of the cache data, a search query used for the search, a search result list in which the data ID of the data included in the cache data is described, and a cache record associated with the generation date and time of the cache data; ,
A cache management apparatus comprising:
前記データベースにデータが追加されたときは、前記変更履歴蓄積手段に変更履歴を追加して当該変更履歴に前記データID、データの追加を示す管理フラグを登録し、
前記データベースのデータが変更あるいは削除されたときは、変更あるいは削除されたデータのデータIDを有する変更履歴を前記変更履歴蓄積手段から検索し、該当する変更履歴がない場合及び管理フラグがデータの追加を示す変更履歴のみが検索された場合は、前記変更履歴蓄積手段に変更履歴を追加して当該変更履歴に前記データID、データの変更あるいは削除を示す管理フラグを登録し、管理フラグがデータの変更あるいは削除を示す変更履歴が検索された場合は、当該変更履歴の管理フラグを更新する変更履歴管理手段を有することを特徴とする請求項2記載のキャッシュ管理装置。
When data is added to the database, a change history is added to the change history storage means, and the management ID indicating the addition of the data ID and data is registered in the change history,
When the data in the database is changed or deleted, the change history having the data ID of the changed or deleted data is searched from the change history storage means, and if there is no corresponding change history, the management flag is added to the data When the change history indicating only the change ID is retrieved, the change history is added to the change history storage means, and the management flag indicating the change or deletion of the data ID or data is registered in the change history. 3. The cache management apparatus according to claim 2, further comprising a change history management unit that updates a management flag of the change history when a change history indicating change or deletion is retrieved.
前記変更履歴蓄積手段から各変更履歴の管理フラグを取得し、当該管理フラグがデータの追加を示している場合はデータが追加された件数をカウントし、それ以外の場合はその変更履歴のデータIDを削除対象リストに追加し、前記変更履歴蓄積手段から全変更履歴を削除する変更履歴更新手段と、
前記件数に基づいて算出した不整合の程度が所定の閾値を超えた場合、前記キャッシュ管理テーブルの全キャッシュレコード及び前記キャッシュの格納された全キャッシュデータを削除し、
前記件数に基づいて算出した不整合の程度が所定の閾値を超えない場合、前記削除対象リストに記載されているデータIDを有する前記キャッシュレコードを前記キャッシュ管理テーブルから削除するとともに、当該キャッシュレコードに対応するキャッシュデータを前記キャッシュから削除するキャッシュ削除手段を有することを特徴とする請求項2又は3記載のキャッシュ管理装置。
The management flag of each change history is acquired from the change history accumulating means, and when the management flag indicates the addition of data, the number of added data is counted, and in other cases, the data ID of the change history Change history update means for deleting the entire change history from the change history storage means,
When the degree of inconsistency calculated based on the number of cases exceeds a predetermined threshold, all cache records in the cache management table and all cache data stored in the cache are deleted,
If the degree of inconsistency calculated based on the number of cases does not exceed a predetermined threshold, the cache record having the data ID described in the deletion target list is deleted from the cache management table, and the cache record 4. The cache management apparatus according to claim 2, further comprising cache deletion means for deleting corresponding cache data from the cache.
前記データベースにデータが追加された件数をカウントし、当該件数に基づいて算出した不整合の程度が所定の閾値を超えた場合、前記キャッシュ管理テーブルの全キャッシュレコード及び前記キャッシュの格納された全キャッシュデータを削除するとともに、前記件数をクリアするキャッシュ削除手段を有することを特徴とする請求項1乃至4のいずれかに記載のキャッシュ管理装置。   When the number of data added to the database is counted and the degree of inconsistency calculated based on the number exceeds a predetermined threshold, all cache records of the cache management table and all caches stored in the cache are stored 5. The cache management apparatus according to claim 1, further comprising a cache deletion unit that deletes data and clears the number of cases. 前記判定手段は、前記生成日時と現在日時を比較し、前記生成日時が現在日時から所定の期間内である場合は、前記取得手段が検索した前記キャッシュレコードに対応する前記キャッシュデータは有効であると判定することを特徴する請求項1乃至5のいずれかに記載のキャッシュ管理装置。   The determination unit compares the generation date and time with the current date and time. If the generation date and time is within a predetermined period from the current date and time, the cache data corresponding to the cache record searched by the acquisition unit is valid. The cache management device according to claim 1, wherein the cache management device is determined. 請求項1乃至6のいずれかに記載のキャッシュ管理装置を構成する各手段としてコンピュータを機能させるためのキャッシュ管理プログラム。   A cache management program for causing a computer to function as each means constituting the cache management device according to claim 1. 請求項7記載のキャッシュ管理プログラムを記録した記録媒体。   A recording medium on which the cache management program according to claim 7 is recorded.
JP2010186031A 2010-08-23 2010-08-23 Cache management device, cache management program, and recording medium Active JP5385874B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2010186031A JP5385874B2 (en) 2010-08-23 2010-08-23 Cache management device, cache management program, and recording medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2010186031A JP5385874B2 (en) 2010-08-23 2010-08-23 Cache management device, cache management program, and recording medium

Publications (2)

Publication Number Publication Date
JP2012043338A true JP2012043338A (en) 2012-03-01
JP5385874B2 JP5385874B2 (en) 2014-01-08

Family

ID=45899532

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2010186031A Active JP5385874B2 (en) 2010-08-23 2010-08-23 Cache management device, cache management program, and recording medium

Country Status (1)

Country Link
JP (1) JP5385874B2 (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101318234B1 (en) * 2012-04-25 2013-10-15 주식회사 비트랜 Data cache method and device for database system
JP2014089627A (en) * 2012-10-31 2014-05-15 Nec Corp Data reading device, data writing device, distribution system and method and program
JP2014120153A (en) * 2012-12-14 2014-06-30 Sap Ag Column smart mechanism for column based database
CN107239467A (en) * 2016-03-29 2017-10-10 北京神州泰岳软件股份有限公司 Data processing method and device based on database
CN109800538A (en) * 2019-02-21 2019-05-24 安徽省川佰科技有限公司 A kind of Sunlight Analysis system that builds a building based on big data
CN110018969A (en) * 2019-03-08 2019-07-16 平安科技(深圳)有限公司 Data cache method, device, computer equipment and storage medium
CN112506973A (en) * 2020-12-14 2021-03-16 ***股份有限公司 Method and device for managing stored data
CN113486037A (en) * 2021-07-27 2021-10-08 北京京东乾石科技有限公司 Cache data updating method, manager and cache server
CN113626458A (en) * 2021-08-19 2021-11-09 咪咕数字传媒有限公司 High-concurrency data updating method, device, equipment and computer storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH06274401A (en) * 1993-03-18 1994-09-30 Nec Corp Distributed data base control system
JP2005267540A (en) * 2004-03-22 2005-09-29 Fuji Xerox Co Ltd File search system, file searching method, and file searching program
JP2008146380A (en) * 2006-12-11 2008-06-26 Sony Computer Entertainment Inc Cache server, control method for it, program, and information storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH06274401A (en) * 1993-03-18 1994-09-30 Nec Corp Distributed data base control system
JP2005267540A (en) * 2004-03-22 2005-09-29 Fuji Xerox Co Ltd File search system, file searching method, and file searching program
JP2008146380A (en) * 2006-12-11 2008-06-26 Sony Computer Entertainment Inc Cache server, control method for it, program, and information storage medium

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101318234B1 (en) * 2012-04-25 2013-10-15 주식회사 비트랜 Data cache method and device for database system
JP2014089627A (en) * 2012-10-31 2014-05-15 Nec Corp Data reading device, data writing device, distribution system and method and program
JP2014120153A (en) * 2012-12-14 2014-06-30 Sap Ag Column smart mechanism for column based database
CN107239467A (en) * 2016-03-29 2017-10-10 北京神州泰岳软件股份有限公司 Data processing method and device based on database
CN109800538A (en) * 2019-02-21 2019-05-24 安徽省川佰科技有限公司 A kind of Sunlight Analysis system that builds a building based on big data
CN109800538B (en) * 2019-02-21 2022-09-13 安徽省川佰科技有限公司 Building sunshine analysis system based on big data
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
CN112506973A (en) * 2020-12-14 2021-03-16 ***股份有限公司 Method and device for managing stored data
CN112506973B (en) * 2020-12-14 2023-12-15 ***股份有限公司 Method and device for managing storage data
CN113486037A (en) * 2021-07-27 2021-10-08 北京京东乾石科技有限公司 Cache data updating method, manager and cache server
CN113626458A (en) * 2021-08-19 2021-11-09 咪咕数字传媒有限公司 High-concurrency data updating method, device, equipment and computer storage medium

Also Published As

Publication number Publication date
JP5385874B2 (en) 2014-01-08

Similar Documents

Publication Publication Date Title
JP5385874B2 (en) Cache management device, cache management program, and recording medium
US8082258B2 (en) Updating an inverted index in a real time fashion
US7945637B2 (en) Server architecture and methods for persistently storing and serving event data
CN111858496B (en) Metadata retrieval method and device, storage medium and electronic equipment
US8386494B2 (en) Providing data structures for determining whether keys of an index are present in a storage system
JP2020529673A5 (en)
US20120203747A1 (en) Method and System for Processing Information of a Stream of Information
KR101496179B1 (en) System and method for searching information based on data absence tagging
CN111859132A (en) Data processing method and device, intelligent equipment and storage medium
EP2761507A1 (en) Efficient cache management in a cluster
JP5322019B2 (en) Predictive caching method for caching related information in advance, system thereof and program thereof
JP5272428B2 (en) Predictive cache method for caching information with high access frequency in advance, system thereof and program thereof
US20180203908A1 (en) Distributed database system and distributed data processing method
JP6225606B2 (en) Database monitoring apparatus, database monitoring method, and computer program
JP2012203792A (en) Validity period calculation device, validity period calculation method, and validity period calculation program
KR20190129474A (en) Apparatus and method for retrieving data
JP5365830B2 (en) Predictive cache method for caching information that is likely to be used, its system, and its program
CN110362535B (en) File management method, device and system
JP2004252789A (en) Information retrieval device, information retrieval method, information retrieval program, and recording medium recorded with same program
JP4825504B2 (en) Data registration / retrieval system and data registration / retrieval method
JP2004310630A (en) Cache control unit
JP5036506B2 (en) Customer information management system, customer information management method, and customer information management program
JP2005107888A (en) Information registering method
JP2011238098A (en) Retrieval device
JP5276391B2 (en) Intelligent content indexing technology

Legal Events

Date Code Title Description
A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20130423

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20131001

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20131004

R150 Certificate of patent or registration of utility model

Ref document number: 5385874

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

Free format text: JAPANESE INTERMEDIATE CODE: R150

S531 Written request for registration of change of domicile

Free format text: JAPANESE INTERMEDIATE CODE: R313531

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350