CN112035479A - Medicine database access method and device and computer equipment - Google Patents

Medicine database access method and device and computer equipment Download PDF

Info

Publication number
CN112035479A
CN112035479A CN202010900115.1A CN202010900115A CN112035479A CN 112035479 A CN112035479 A CN 112035479A CN 202010900115 A CN202010900115 A CN 202010900115A CN 112035479 A CN112035479 A CN 112035479A
Authority
CN
China
Prior art keywords
data
bloom filter
database
redis
medicine
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010900115.1A
Other languages
Chinese (zh)
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.)
Shenzhen Ping An Medical Health Technology Service Co Ltd
Original Assignee
Ping An Medical and Healthcare Management 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 Ping An Medical and Healthcare Management Co Ltd filed Critical Ping An Medical and Healthcare Management Co Ltd
Priority to CN202010900115.1A priority Critical patent/CN112035479A/en
Publication of CN112035479A publication Critical patent/CN112035479A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2255Hash tables
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computational Linguistics (AREA)
  • Medical Treatment And Welfare Office Work (AREA)

Abstract

The application relates to the field of digital medical treatment, and discloses a method for accessing a medicine database, which comprises the following steps: acquiring an access request for accessing a medicine database sent by a user side; inputting keyword information into a bloom filter pre-arranged in Redis, and performing mapping analysis operation to obtain an analysis result, wherein one end of the Redis is in data connection with the user side, and the other end of the Redis is in data connection with the medicine database; obtaining an analysis result fed back by a bloom filter in the Redis; judging whether the access request needs to be sent to the medicine database according to the analysis result; and if so, sending the access request to the medicine database for data access. By embedding the bloom filter in the Redis system, the data of the common medicines on the medicine network is filtered through the bloom filter in the Redis, the situation that judgment is carried out after all requests access the database is avoided, the data caching effect is achieved, and the cached data does not disappear when the system is restarted.

Description

Medicine database access method and device and computer equipment
Technical Field
The application relates to the field of digital medical treatment, in particular to a method and a device for accessing a medicine database and computer equipment.
Background
With the development of the internet, access to databases is more frequent. Some malicious attacks such as crawlers can access the database maliciously, and occupy resources. The pressure on the underlying data sources is too great, and some underlying data sources do not have high concurrency, such as mysql, and generally the operation capacity of a single machine is less than or equal to 1000-QPS. The existing solution is to establish a cache between machine physical storages, and place hot data into the cache to relieve the pressure of accessing the database, but the cache is based on a Java memory, and the restart is invalid. And on the premise of a distributed architecture, the cache function cannot be played, and the storage of large data volume is not supported.
Disclosure of Invention
The main purpose of the application is to provide access to a medical database, and aim to solve the technical problems that the dictionary coding rules of the medical insurance data are different and the coded information cannot be derived in the same standard in a centralized manner.
The application provides an access method of a medicine database, which comprises the following steps:
acquiring an access request for accessing a medicine database sent by a user side, wherein the access request carries keyword information;
inputting the keyword information into a bloom filter pre-arranged in Redis, and performing mapping analysis operation to obtain an analysis result, wherein one end of the Redis is in data connection with the user side, and the other end of the Redis is in data connection with the medicine database;
obtaining an analysis result fed back by a bloom filter in the Redis;
judging whether the access request needs to be sent to the medicine database according to the analysis result;
and if so, sending the access request to the medicine database for data access.
Preferably, the step of obtaining an access request sent by the user side for accessing the medical database includes:
acquiring module coordinate data of the extension assembly;
associating the extension component in the Redis according to the module coordinate data through a deployment file;
linking the bloom filter within the expansion component to form a Redis carrying bloom filter.
Preferably, the step of linking the bloom filter within the expansion assembly to form a Redis carrying bloom filter is followed by:
extracting hot spot data in the medicine database;
adding the hotspot data to an element set of the bloom filter in a hash function mapping mode;
judging whether all the hot spot data are added completely;
and if so, associating the Redis carrying the bloom filter after the hot spot data is added between the user side and the medicine database.
Preferably, the step of extracting hot spot data in the medical class database includes:
judging whether first medicine data with the medicine purchase quantity exceeding a first preset value or second medicine data with the access times exceeding a second preset value exists in the medicine database;
and marking the first medicine data and the second medicine data as the hot spot data.
Preferably, the step of adding the hotspot data to the set of elements of the bloom filter by means of hash function mapping includes:
acquiring the number of elements included in the hotspot data;
calculating the data storage length occupying the bloom filter through a first calculation formula according to the number of elements included in the hotspot data, wherein the first calculation formula is
Figure BDA0002659509380000021
n represents the number of elements included in the hotspot data, P represents a preset false alarm rate, and m represents the data storage length occupying the bloom filter;
upon occupying the data store of the bloom filterThe length and the number of elements included in the hotspot data are calculated according to a second formula, wherein the number of hash functions needing to be called is calculated according to the second formula
Figure BDA0002659509380000022
k represents the number of hash functions;
selecting hash functions with the number equal to that of the hash functions to form the hash functions according to the number of the hash functions;
inputting the hotspot data into the hash function to obtain a hash value:
adding the hash value to the set of elements of the bloom filter.
Preferably, the analysis result includes a hash value corresponding to the access request, and the step of determining whether the access request needs to be sent to the pharmaceutical-type database according to the analysis result includes:
analyzing whether the data type of the hash value corresponding to the access request is the same as the data type of the hash value of the hotspot data prestored in the bloom filter or not;
if so, judging that the access data corresponding to the access request exists in the medicine database, and judging that the access request needs to be sent to the medicine database.
Preferably, after the step of obtaining the access request sent by the user end to access the medical database, the method includes:
according to the formula
Figure BDA0002659509380000031
Evaluating whether the access state of the user side in a preset time period exceeds a preset condition, wherein F (x) represents t1Time to t2Access state quantity at time, xt1Represents t1Access state quantity at time, xt2Represents t2P (x) represents the access information type concentration;
if yes, judging whether the user side is a member account number of a preset member library;
and if so, generating an information instruction for inputting the keyword information into a bloom filter which is arranged in Redis in advance to perform mapping analysis operation, and obtaining an analysis result.
The application also provides an access device for a medical database, comprising:
the system comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is used for acquiring an access request for accessing a medicine database sent by a user side, and the access request carries keyword information;
the analysis module is used for inputting the keyword information into a bloom filter which is pre-arranged in Redis, and carrying out mapping analysis operation to obtain an analysis result, wherein one end of the Redis is in data connection with the user side, and the other end of the Redis is in data connection with the medicine database;
the second acquisition module is used for acquiring an analysis result fed back by the bloom filter in the Redis;
the first judgment module is used for judging whether the access request needs to be sent to the medicine database according to the analysis result;
and the sending module is used for sending the access request to the medicine database to access data if the access request needs to be sent to the medicine database.
The present application further provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.
The present application also provides a computer-readable storage medium having stored thereon a computer program which, when being executed by a processor, carries out the steps of the method as described above.
According to the method and the device, the bloom filter is embedded in the Redis system, so that the data of the common medicines on the medicine network are filtered through the bloom filter in the Redis, judgment is carried out after all requests need to access the database, the effect of data caching is achieved, and the cached data does not disappear when the system is restarted.
Drawings
Fig. 1 is a schematic flow chart illustrating an access method of a medical database according to an embodiment of the present application;
FIG. 2 is a schematic diagram of an accessing device of a medical database according to an embodiment of the present application;
fig. 3 is a schematic diagram of an internal structure of a computer device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
Referring to fig. 1, a method for accessing a medical database according to an embodiment of the present application includes:
s1: acquiring an access request for accessing a medicine database sent by a user side, wherein the access request carries keyword information;
s2: inputting the keyword information into a bloom filter pre-arranged in Redis, and performing mapping analysis operation to obtain an analysis result, wherein one end of the Redis is in data connection with the user side, and the other end of the Redis is in data connection with the medicine database;
s3: obtaining an analysis result fed back by a bloom filter in the Redis;
s4: judging whether the access request needs to be sent to the medicine database according to the analysis result;
s5: and if so, sending the access request to the medicine database for data access.
In the embodiment of the present application, the mapping analysis operation includes, but is not limited to, an analysis operation process of performing a hash operation on the keyword information to obtain a compressed and encrypted hash value. And judging whether the access request needs to be sent to the medicine database for database access or not by comparing the hash values. The medical database includes, but is not limited to, a medical web database. The bloom filter is arranged in the Redis and used as an information filter between the user side and the medicine database, so that invalid accesses which do not need to start the medicine database are quickly screened out, the safety of the medicine database is improved, and meanwhile, the bloom filter is arranged in the Redis to filter data, so that continuous support of multiple concurrent accesses with high magnitude of order is realized. The bloom filter of this application is laid in Redis, and is different from the bloom filter of laying in the Java framework, and the bloom filter of this application is laid in Redis through extension subassembly, realizes that the storage data in the bloom filter keeps lasting effectively after the initialization operation, even if the outage restarts and does not influence the storage data after the initialization in the bloom filter, satisfies the filterable demand of the real-time continuous access of medicine class database.
Further, before the step S1 of obtaining the access request sent by the user end to access the medical database, the method includes:
s101: acquiring module coordinate data of the extension assembly;
s102: associating the extension component in the Redis according to the module coordinate data through a deployment file;
s103: linking the bloom filter within the expansion component to form a Redis carrying bloom filter.
The Redis of the embodiment of the application is a version of 4.0, an extension module is added into the Redis, and then a bloom filter is added into the Redis in a module form to form the Redis carrying the bloom filter, which is used as an information filter between a user side and a medicine database. The module coordinate of the extension component is introduced into the POM file through the deployment file, and the module is added.
In another embodiment of the present application, a bloom filter is directly deployed in the Redis by a container docker. The layout instruction is as follows, "> docker pull redislabs/reobloom # pull mirror image; a > docker run-p6379:6379 redislabs/reboom # run vessel; and the Redis service in the Redis-cli # connection container realizes the expansion of the bloom filter by using Redis.
Further, after the step S103 of linking the bloom filter into the extension component to form a Redis carrying bloom filter, the method includes:
s104: extracting hot spot data in the medicine database;
s105: adding the hotspot data to an element set of the bloom filter in a hash function mapping mode;
s106: judging whether all the hot spot data are added completely;
s107: and if so, associating the Redis carrying the bloom filter after the hot spot data is added between the user side and the medicine database.
In the embodiment of the application, after a bloom filter in Redis is constructed, hot spot data in a medicine database is added to the Redis in an element adding mode. When an element is added to the set, the element is mapped by K hash functions to K points in a bit array in the bloom filter and their corresponding storage bits are assigned a value of 1. The hot spot data in the medicine database is added into the data set of the bloom filter in the element adding mode, for example, the data of common medicines on a medicine network is used as the hot spot data. The hot spot data are added into the bloom filter to filter access except the hot spot data, so that efficient access of the medical database in an access peak period is improved, the hot spot data represent data which are certainly in the database, if the access data are not the hot spot data, the fact that corresponding data do not exist in the database is directly judged, data links from the access requests to the medical database are intercepted, and all the access requests are prevented from being sent to the medical database through the filtering of the bloom filter to access the database.
Further, the step S104 of extracting the hot spot data in the medicine database includes:
s1041: judging whether first medicine data with the medicine purchase quantity exceeding a first preset value or second medicine data with the access times exceeding a second preset value exists in the medicine database;
s1042: and marking the first medicine data and the second medicine data as the hot spot data.
According to the method and the device, the purchase quantity exceeds a certain preset value, or the accessed coefficient exceeds a certain value, and the data are marked as hot spot data. Through data screening and filtration of the bloom filter, effective management and control of access requests are achieved in specific time periods, such as access data peak time periods, and effective utilization rate of the database is improved. When the access time period is not the peak time period, or the access request of the current time period is lower than a certain threshold value, the database can be directly connected for data access.
Further, the step S105 of adding the hotspot data to the set of elements of the bloom filter by means of hash function mapping includes:
s1051: acquiring the number of elements included in the hotspot data;
s1052: calculating the data storage length occupying the bloom filter through a first calculation formula according to the number of elements included in the hotspot data, wherein the first calculation formula is
Figure BDA0002659509380000061
n represents the number of elements included in the hotspot data, P represents a preset false alarm rate, and m represents the data storage length occupying the bloom filter;
s1053: calculating the number of hash functions to be called according to a second formula according to the data storage length occupying the bloom filter and the number of elements included in the hotspot data, wherein the second formula is calculated as
Figure BDA0002659509380000062
k represents the number of hash functions;
s1054: selecting hash functions with the number equal to that of the hash functions to form the hash functions according to the number of the hash functions;
s1055: inputting the hotspot data into the hash function to obtain a hash value:
s1056: adding the hash value to the set of elements of the bloom filter.
According to the embodiment of the application, mapping operation is carried out through a plurality of hash functions, hotspot data with unfixed length are mapped into hash values with fixed length to be stored, and the corresponding hash values are all set to be 1. During retrieval, the keyword information is also subjected to Hash mapping operation to obtain a Hash value, if the Hash values are the same, the element storage bit of the bloom filter is set to be 1, and whether the element storage bits are all 1 or not is observed, so that the detected element included in the access request can be judged in the data set, and the data corresponding to the access request exists in the medicine database: if any bit of the element storage bit is 0, the detected element is not in the data set of the bloom filter, which indicates that the data corresponding to the access request does not exist in the medical database, and the access request can be intercepted.
The length of the bloom filter directly influences the false alarm rate, the longer the bloom filter is, the smaller the false alarm rate is, but the calculation amount is large, and the response is slow. However, all bit array bits of the bloom filter which is too small are filled with 1 quickly, the capacity of the bloom filter can reach saturation quickly, any value can be returned after the bloom filter is saturated, and the filtering purpose cannot be achieved. The number of the hash functions also needs to be balanced, the speed of setting the bit position of the bloom filter to be 1 is faster when the number of the hash functions is larger, and the filtering efficiency of the bloom filter is lower; however, if the number is too small, the false alarm rate becomes high. The method and the device determine the length of the storage data of the bloom filter according to a preset false alarm rate, and then determine the number of hash functions according to the number of inserted elements and the false alarm rate.
The bloom filter distributed in the Redis can create a new bloom filter on an original bloom filter once the capacity maximum value is reached, and can cover the original bloom filter after copying data set elements in the original bloom filter, so that the reinitialization is not needed, the situations of power failure and disappearance due to restarting can be avoided, and the data maintenance cost is reduced. The hot spot data storage of this application just need carry out once and can used repeatedly when laying the bloom filter in the initialization process in the bloom filter, and the accessible sets for the duration domain, regularly through the update instruction, and the automatic data set that obtains the hot spot data of update carries out in the bloom filter updates.
Further, the step S4 of determining whether the access request needs to be sent to the medical database according to the analysis result, where the analysis result includes a hash value corresponding to the access request, includes:
s41: analyzing whether the data type of the hash value corresponding to the access request is the same as the data type of the hash value of the hotspot data prestored in the bloom filter or not;
s42: if so, judging that the access data corresponding to the access request exists in the medicine database, and judging that the access request needs to be sent to the medicine database.
According to the embodiment of the application, a bloom filter for a target container of a medicine database is constructed at O (n) time complexity, and the used space is far smaller than that of the target container, so that whether a certain element is contained in the target container can be calculated at O (1) time complexity. For example, the input scale is taken as an x-axis, the time/space taken is taken as a y-axis, O (1) is y ═ 1, and is a constant, and when x changes, y does not change and is a line parallel to the x-axis. If the element returned by the bloom filter does not exist, namely the storage bit is 0 in the comparison of the hash values, the element is not necessarily contained in the medical database, the access request is invalid, interception can be carried out, and the access request does not need to be sent to the database for access.
Further, after the step S1 of obtaining the access request sent by the user end to access the medical database, the method includes:
s11: according to the formula
Figure BDA0002659509380000081
Evaluating whether the access state of the user side in a preset time period exceeds a preset condition, wherein F (x) represents t1Time to t2Access state quantity at time, xt1Represents t1Of time of dayAccess state quantity, xt2Represents t2P (x) represents the access information type concentration;
s12: if yes, judging whether the user side is a member account number of a preset member library;
s13: and if so, generating an information instruction for inputting the keyword information into a bloom filter which is arranged in Redis in advance to perform mapping analysis operation, and obtaining an analysis result.
In the embodiment of the application, the access state of the user side is analyzed, the filtering of the access request is further enhanced, and when repeated intensive accesses are received for many times within a certain time period, the member account is started to screen malicious accesses of non-member users, so that the safety of the medical database is enhanced, and the access effectiveness of the medical database is improved.
Referring to fig. 2, an access apparatus for a medical database according to an embodiment of the present application includes:
the system comprises a first acquisition module 1, a first storage module and a second storage module, wherein the first acquisition module is used for acquiring an access request for accessing a medicine database sent by a user side, and the access request carries keyword information;
the analysis module 2 is configured to input the keyword information into a bloom filter pre-arranged in the Redis, and perform mapping analysis operation to obtain an analysis result, where one end of the Redis is connected to the user side data, and the other end of the Redis is connected to the pharmaceutical database data;
a second obtaining module 3, configured to obtain an analysis result fed back by a bloom filter in the Redis;
the first judgment module 4 is used for judging whether the access request needs to be sent to the medicine database according to the analysis result;
and the sending module 5 is used for sending the access request to the medicine database to access data if the access request needs to be sent to the medicine database.
In the embodiment of the present application, the mapping analysis operation includes, but is not limited to, an analysis operation process of performing a hash operation on the keyword information to obtain a compressed and encrypted hash value. And judging whether the access request needs to be sent to the medicine database for database access or not by comparing the hash values. The medical database includes, but is not limited to, a medical web database. The bloom filter is arranged in the Redis and used as an information filter between the user side and the medicine database, so that invalid accesses which do not need to start the medicine database are quickly screened out, the safety of the medicine database is improved, and meanwhile, the bloom filter is arranged in the Redis to filter data, so that continuous support of multiple concurrent accesses with high magnitude of order is realized. The bloom filter of this application is laid in Redis, and is different from the bloom filter of laying in the Java framework, and the bloom filter of this application is laid in Redis through extension subassembly, realizes that the storage data in the bloom filter keeps lasting effectively after the initialization operation, even if the outage restarts and does not influence the storage data after the initialization in the bloom filter, satisfies the filterable demand of the real-time continuous access of medicine class database.
Further, the access device of the medicine class database comprises:
the third acquisition module is used for acquiring module coordinate data of the extension assembly;
a first associating module, configured to associate the extension component in the Redis according to the module coordinate data through a deployment file;
and the linking module is used for linking the bloom filter in the expansion assembly to form the Redis carrying the bloom filter.
The Redis of the embodiment of the application is a version of 4.0, an extension module is added into the Redis, and then a bloom filter is added into the Redis in a module form to form the Redis carrying the bloom filter, which is used as an information filter between a user side and a medicine database. The module coordinate of the extension component is introduced into the POM file through the deployment file, and the module is added.
In another embodiment of the present application, a bloom filter is directly deployed in the Redis by a container docker. The layout instruction is as follows, "> docker pull redislabs/reobloom # pull mirror image; a > docker run-p6379:6379 redislabs/reboom # run vessel; and the Redis service in the Redis-cli # connection container realizes the expansion of the bloom filter by using Redis.
Further, the access device of the medicine class database comprises:
the extraction module is used for extracting the hot spot data in the medicine database;
the adding module is used for adding the hotspot data to the element set of the bloom filter in a hash function mapping mode;
the second judgment module is used for judging whether all the hot spot data are added completely;
and the second association module is used for associating the Redis carrying the bloom filter after the hot spot data is added between the user side and the medicine database if the addition is finished.
In the embodiment of the application, after a bloom filter in Redis is constructed, hot spot data in a medicine database is added to the Redis in an element adding mode. When an element is added to the set, the element is mapped by K hash functions to K points in a bit array in the bloom filter and their corresponding storage bits are assigned a value of 1. The hot spot data in the medicine database is added into the data set of the bloom filter in the element adding mode, for example, the data of common medicines on a medicine network is used as the hot spot data. The hot spot data are added into the bloom filter to filter access except the hot spot data, so that efficient access of the medical database in an access peak period is improved, the hot spot data represent data which are certainly in the database, if the access data are not the hot spot data, the fact that corresponding data do not exist in the database is directly judged, data links from the access requests to the medical database are intercepted, and all the access requests are prevented from being sent to the medical database through the filtering of the bloom filter to access the database.
Further, an extraction module, comprising:
the judging unit is used for judging whether first medicine data with the medicine purchase quantity exceeding a first preset value or second medicine data with the access times exceeding a second preset value exists in the medicine database;
and the marking unit is used for marking the first medicine data and the second medicine data as the hot spot data.
According to the method and the device, the purchase quantity exceeds a certain preset value, or the accessed coefficient exceeds a certain value, and the data are marked as hot spot data. Through data screening and filtration of the bloom filter, effective management and control of access requests are achieved in specific time periods, such as access data peak time periods, and effective utilization rate of the database is improved. When the access time period is not the peak time period, or the access request of the current time period is lower than a certain threshold value, the database can be directly connected for data access.
Further, an add module comprising:
an obtaining unit, configured to obtain the number of elements included in the hotspot data;
a first calculating unit, configured to calculate, according to the number of elements included in the hotspot data, a data storage length occupying the bloom filter by using a first calculation formula, where the first calculation formula is
Figure BDA0002659509380000111
n represents the number of elements included in the hotspot data, P represents a preset false alarm rate, and m represents the data storage length occupying the bloom filter;
a second calculating unit, configured to calculate, according to a second formula, the number of hash functions to be called according to the data storage length occupying the bloom filter and the number of elements included in the hotspot data, where the second formula is calculated as
Figure BDA0002659509380000112
k represents the number of hash functions;
the selecting unit is used for selecting the hash functions with the number equal to that of the hash functions according to the number of the hash functions to form the hash functions;
an input unit, configured to input the hotspot data into the hash function to obtain a hash value:
an adding unit, configured to add the hash value to the set of elements of the bloom filter.
According to the embodiment of the application, mapping operation is carried out through a plurality of hash functions, hotspot data with unfixed length are mapped into hash values with fixed length to be stored, and the corresponding hash values are all set to be 1. During retrieval, the keyword information is also subjected to Hash mapping operation to obtain a Hash value, if the Hash values are the same, the element storage bit of the bloom filter is set to be 1, and whether the element storage bits are all 1 or not is observed, so that the detected element included in the access request can be judged in the data set, and the data corresponding to the access request exists in the medicine database: if any bit of the element storage bit is 0, the detected element is not in the data set of the bloom filter, which indicates that the data corresponding to the access request does not exist in the medical database, and the access request can be intercepted.
The length of the bloom filter directly influences the false alarm rate, the longer the bloom filter is, the smaller the false alarm rate is, but the calculation amount is large, and the response is slow. However, all bit array bits of the bloom filter which is too small are filled with 1 quickly, the capacity of the bloom filter can reach saturation quickly, any value can be returned after the bloom filter is saturated, and the filtering purpose cannot be achieved. The number of the hash functions also needs to be balanced, the speed of setting the bit position of the bloom filter to be 1 is faster when the number of the hash functions is larger, and the filtering efficiency of the bloom filter is lower; however, if the number is too small, the false alarm rate becomes high. The method and the device determine the length of the storage data of the bloom filter according to a preset false alarm rate, and then determine the number of hash functions according to the number of inserted elements and the false alarm rate.
The bloom filter distributed in the Redis can create a new bloom filter on an original bloom filter once the capacity maximum value is reached, and can cover the original bloom filter after copying data set elements in the original bloom filter, so that the reinitialization is not needed, the situations of power failure and disappearance due to restarting can be avoided, and the data maintenance cost is reduced. The hot spot data storage of this application just need carry out once and can used repeatedly when laying the bloom filter in the initialization process in the bloom filter, and the accessible sets for the duration domain, regularly through the update instruction, and the automatic data set that obtains the hot spot data of update carries out in the bloom filter updates.
Further, the analysis result includes a hash value corresponding to the access request, and the first determining module 4 includes:
the analysis unit is used for analyzing whether the data type of the hash value corresponding to the access request is the same as the data type of the hash value of the hotspot data prestored in the bloom filter or not;
and the judging unit is used for judging that the access data corresponding to the access request exists in the medicine database if the data type of the hash value of the hotspot data prestored in the bloom filter is the same as that of the hash value of the hotspot data prestored in the bloom filter, and judging that the access request needs to be sent to the medicine database.
According to the embodiment of the application, a bloom filter for a target container of a medicine database is constructed at O (n) time complexity, and the used space is far smaller than that of the target container, so that whether a certain element is contained in the target container can be calculated at O (1) time complexity. For example, the input scale is taken as an x-axis, the time/space taken is taken as a y-axis, O (1) is y ═ 1, and is a constant, and when x changes, y does not change and is a line parallel to the x-axis. If the element returned by the bloom filter does not exist, namely the storage bit is 0 in the comparison of the hash values, the element is not necessarily contained in the medical database, the access request is invalid, interception can be carried out, and the access request does not need to be sent to the database for access.
Further, the access device of the medicine class database comprises:
an evaluation module for evaluating the equation
Figure BDA0002659509380000121
Evaluating whether the access state of the user side in a preset time period exceeds a preset condition, wherein F (x) represents t1Time to t2Access state quantity at time, xt1Represents t1Access state quantity at time, xt2Represents t2P (x) represents the access information type concentration;
the third judgment module is used for judging whether the user side is a member account number of a preset member library or not if the preset condition is exceeded;
and the generating module is used for generating an information instruction for inputting the keyword information into a bloom filter which is pre-arranged in Redis to perform mapping analysis operation if the keyword information is a member account number of a preset member library, so as to obtain an analysis result.
In the embodiment of the application, the access state of the user side is analyzed, the filtering of the access request is further enhanced, and when repeated intensive accesses are received for many times within a certain time period, the member account is started to screen malicious accesses of non-member users, so that the safety of the medical database is enhanced, and the access effectiveness of the medical database is improved.
Referring to fig. 3, a computer device, which may be a server and whose internal structure may be as shown in fig. 3, is also provided in the embodiment of the present application. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the computer designed processor is used to provide computational and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store all data required for the access process of the medical-type database. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a method of accessing a medical-type database.
The processor executes the method for accessing the medicine database, and comprises the following steps: acquiring an access request for accessing a medicine database sent by a user side, wherein the access request carries keyword information; inputting the keyword information into a bloom filter pre-arranged in Redis, and performing mapping analysis operation to obtain an analysis result, wherein one end of the Redis is in data connection with the user side, and the other end of the Redis is in data connection with the medicine database; obtaining an analysis result fed back by a bloom filter in the Redis; judging whether the access request needs to be sent to the medicine database according to the analysis result; and if so, sending the access request to the medicine database for data access.
According to the computer equipment, the bloom filter is embedded in the Redis system, so that the data of the common medicines on the medicine network are filtered through the bloom filter in the Redis, the situation that judgment is carried out after all requests access the database is avoided, the effect of data caching is achieved, and the cached data does not disappear when the computer equipment is restarted.
In an embodiment, the step of the processor obtaining the access request sent by the user side to access the medicine database includes: acquiring module coordinate data of the extension assembly; associating the extension component in the Redis according to the module coordinate data through a deployment file; linking the bloom filter within the expansion component to form a Redis carrying bloom filter.
In one embodiment, the step of linking the bloom filter within the expansion component by the processor to form a Redis carrying bloom filter includes: extracting hot spot data in the medicine database; adding the hotspot data to an element set of the bloom filter in a hash function mapping mode; judging whether all the hot spot data are added completely; and if so, associating the Redis carrying the bloom filter after the hot spot data is added between the user side and the medicine database.
In one embodiment, the step of extracting the hot spot data in the medical class database by the processor includes: judging whether first medicine data with the medicine purchase quantity exceeding a first preset value or second medicine data with the access times exceeding a second preset value exists in the medicine database; and marking the first medicine data and the second medicine data as the hot spot data.
In an embodiment, the step of adding the hotspot data to the set of elements of the bloom filter by the processor through a hash function mapping includes: acquiring the number of elements included in the hotspot data; calculating the data storage length occupying the bloom filter through a first calculation formula according to the number of elements included in the hotspot data, wherein the first calculation formula is
Figure BDA0002659509380000141
n represents the number of elements included in the hotspot data, P represents a preset false alarm rate, and m represents the data storage length occupying the bloom filter; calculating the number of hash functions to be called according to a second formula according to the data storage length occupying the bloom filter and the number of elements included in the hotspot data, wherein the second formula is calculated as
Figure BDA0002659509380000142
k represents the number of hash functions; selecting hash functions with the number equal to that of the hash functions to form the hash functions according to the number of the hash functions; inputting the hotspot data into the hash function to obtain a hash value: adding the hash value to the set of elements of the bloom filter.
In one embodiment, the analysis result includes a hash value corresponding to the access request, and the step of determining, by the processor, whether the access request needs to be sent to the medical-type database according to the analysis result includes: analyzing whether the data type of the hash value corresponding to the access request is the same as the data type of the hash value of the hotspot data prestored in the bloom filter or not; if so, judging that the access data corresponding to the access request exists in the medicine database, and judging that the access request needs to be sent to the medicine database.
In an embodiment, after the step of the processor obtaining an access request sent by the user side to access the medical-type database, the method includes: according to the formula
Figure BDA0002659509380000143
Evaluating whether the access state of the user side in a preset time period exceeds a preset condition, wherein F (x) represents t1Time to t2Access state quantity at time, xt1Represents t1Access state quantity at time, xt2Represents t2P (x) represents the access information type concentration; if yes, judging whether the user side is a member account number of a preset member library; and if so, generating an information instruction for inputting the keyword information into a bloom filter which is arranged in Redis in advance to perform mapping analysis operation, and obtaining an analysis result.
Those skilled in the art will appreciate that the architecture shown in fig. 3 is only a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects may be applied.
An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, the computer program, when executed by a processor, implementing a method for accessing a medical-type database, including: acquiring an access request for accessing a medicine database sent by a user side, wherein the access request carries keyword information; inputting the keyword information into a bloom filter pre-arranged in Redis, and performing mapping analysis operation to obtain an analysis result, wherein one end of the Redis is in data connection with the user side, and the other end of the Redis is in data connection with the medicine database; obtaining an analysis result fed back by a bloom filter in the Redis; judging whether the access request needs to be sent to the medicine database according to the analysis result; and if so, sending the access request to the medicine database for data access.
According to the computer-readable storage medium, the bloom filter is embedded in the Redis system, so that the data of the common medicines on the medicine network are filtered through the bloom filter in the Redis, the situation that all requests need to access the database and then are judged is avoided, the effect of data caching is achieved, and the cached data does not disappear when the system is restarted.
In an embodiment, the step of the processor obtaining the access request sent by the user side to access the medicine database includes: acquiring module coordinate data of the extension assembly; associating the extension component in the Redis according to the module coordinate data through a deployment file; linking the bloom filter within the expansion component to form a Redis carrying bloom filter.
In one embodiment, the step of linking the bloom filter within the expansion component by the processor to form a Redis carrying bloom filter includes: extracting hot spot data in the medicine database; adding the hotspot data to an element set of the bloom filter in a hash function mapping mode; judging whether all the hot spot data are added completely; and if so, associating the Redis carrying the bloom filter after the hot spot data is added between the user side and the medicine database.
In one embodiment, the step of extracting the hot spot data in the medical class database by the processor includes: judging whether first medicine data with the medicine purchase quantity exceeding a first preset value or second medicine data with the access times exceeding a second preset value exists in the medicine database; and marking the first medicine data and the second medicine data as the hot spot data.
In an embodiment, the step of adding the hotspot data to the set of elements of the bloom filter by the processor through a hash function mapping includes: acquiring the number of elements included in the hotspot data; calculating the data storage length occupying the bloom filter through a first calculation formula according to the number of elements included in the hotspot data, wherein the first calculation formula is
Figure BDA0002659509380000161
n represents the number of elements included in the hotspot data, P represents a preset false alarm rate, and m represents the data storage length occupying the bloom filter; calculating the number of hash functions to be called according to a second formula according to the data storage length occupying the bloom filter and the number of elements included in the hotspot data, wherein the second formula is calculated as
Figure BDA0002659509380000162
k represents the number of hash functions; selecting hash functions with the number equal to that of the hash functions to form the hash functions according to the number of the hash functions; inputting the hotspot data into the hash function to obtain a hash value: adding the hash value to the set of elements of the bloom filter.
In one embodiment, the analysis result includes a hash value corresponding to the access request, and the step of determining, by the processor, whether the access request needs to be sent to the medical-type database according to the analysis result includes: analyzing whether the data type of the hash value corresponding to the access request is the same as the data type of the hash value of the hotspot data prestored in the bloom filter or not; if so, judging that the access data corresponding to the access request exists in the medicine database, and judging that the access request needs to be sent to the medicine database.
In an embodiment, after the step of the processor obtaining an access request sent by the user side to access the medical-type database, the method includes: according to the formula
Figure BDA0002659509380000163
Evaluating whether the access state of the user side in a preset time period exceeds a preset condition, wherein F (x) represents t1Time to t2Access state quantity at time, xt1Represents t1Access state quantity at time, xt2Represents t2The access state quantity at time P (x) represents the accessInformation type concentration; if yes, judging whether the user side is a member account number of a preset member library; and if so, generating an information instruction for inputting the keyword information into a bloom filter which is arranged in Redis in advance to perform mapping analysis operation, and obtaining an analysis result.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium provided herein and used in the examples may include non-volatile and/or volatile memory. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), double-rate SDRAM (SSRSDRAM), Enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and bus dynamic RAM (RDRAM).
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, apparatus, article, or method. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, apparatus, article, or method that includes the element.
The above description is only a preferred embodiment of the present application, and not intended to limit the scope of the present application, and all modifications of equivalent structures and equivalent processes, which are made by the contents of the specification and the drawings of the present application, or which are directly or indirectly applied to other related technical fields, are also included in the scope of the present application.

Claims (10)

1. A method for accessing a medical database, comprising:
acquiring an access request for accessing a medicine database sent by a user side, wherein the access request carries keyword information;
inputting the keyword information into a bloom filter pre-arranged in Redis, and performing mapping analysis operation to obtain an analysis result, wherein one end of the Redis is in data connection with the user side, and the other end of the Redis is in data connection with the medicine database;
obtaining an analysis result fed back by a bloom filter in the Redis;
judging whether the access request needs to be sent to the medicine database according to the analysis result;
and if so, sending the access request to the medicine database for data access.
2. The method for accessing a medical database according to claim 1, wherein the step of obtaining the access request sent by the user terminal to access the medical database comprises:
acquiring module coordinate data of the extension assembly;
associating the extension component in the Redis according to the module coordinate data through a deployment file;
linking the bloom filter within the expansion component to form a Redis carrying bloom filter.
3. The method of accessing a medical-type database of claim 2, wherein the step of linking the bloom filter within the expansion component to form a Redis carrying bloom filter is followed by the step of:
extracting hot spot data in the medicine database;
adding the hotspot data to an element set of the bloom filter in a hash function mapping mode;
judging whether all the hot spot data are added completely;
and if so, associating the Redis carrying the bloom filter after the hot spot data is added between the user side and the medicine database.
4. The method of claim 3, wherein the step of extracting hot spot data in the medical database comprises:
judging whether first medicine data with the medicine purchase quantity exceeding a first preset value or second medicine data with the access times exceeding a second preset value exists in the medicine database;
and marking the first medicine data and the second medicine data as the hot spot data.
5. The method of claim 3, wherein the step of adding the hotspot data to the set of elements of the bloom filter by means of hash function mapping comprises:
acquiring the number of elements included in the hotspot data;
calculating the data storage length occupying the bloom filter through a first calculation formula according to the number of elements included in the hotspot data, wherein the first calculation formula is
Figure FDA0002659509370000021
n represents the number of elements included in the hotspot data, P represents a preset false alarm rate, and m represents the data storage length occupying the bloom filter;
according to the length of data storage occupying the bloom filter, anThe number of elements included in the hotspot data is calculated according to a second formula, wherein the number of hash functions needing to be called is calculated according to the second formula
Figure FDA0002659509370000022
k represents the number of hash functions;
selecting hash functions with the number equal to that of the hash functions to form the hash functions according to the number of the hash functions;
inputting the hotspot data into the hash function to obtain a hash value:
adding the hash value to the set of elements of the bloom filter.
6. The method of claim 1, wherein the analysis result includes a hash value corresponding to the access request, and the step of determining whether the access request needs to be sent to the medical database according to the analysis result comprises:
analyzing whether the data type of the hash value corresponding to the access request is the same as the data type of the hash value of the hotspot data prestored in the bloom filter or not;
if so, judging that the access data corresponding to the access request exists in the medicine database, and judging that the access request needs to be sent to the medicine database.
7. The method for accessing a medical database according to claim 1, wherein the step of obtaining the access request sent by the user end to access the medical database comprises:
according to the formula
Figure FDA0002659509370000031
Evaluating whether the access state of the user side in a preset time period exceeds a preset condition, wherein F (x) represents t1Time to t2Access state quantity at time, xt1Represents t1Access state quantity at time, xt2Represents t2P (x) represents the access information type concentration;
if yes, judging whether the user side is a member account number of a preset member library;
and if so, generating an information instruction for inputting the keyword information into a bloom filter which is arranged in Redis in advance to perform mapping analysis operation, and obtaining an analysis result.
8. An access device for a medical-type database, comprising:
the system comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is used for acquiring an access request for accessing a medicine database sent by a user side, and the access request carries keyword information;
the analysis module is used for inputting the keyword information into a bloom filter which is pre-arranged in Redis, and carrying out mapping analysis operation to obtain an analysis result, wherein one end of the Redis is in data connection with the user side, and the other end of the Redis is in data connection with the medicine database;
the second acquisition module is used for acquiring an analysis result fed back by the bloom filter in the Redis;
the first judgment module is used for judging whether the access request needs to be sent to the medicine database according to the analysis result;
and the sending module is used for sending the access request to the medicine database to access data if the access request needs to be sent to the medicine database.
9. A computer device comprising a memory and a processor, the memory storing a computer program, wherein the processor implements the steps of the method of any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
CN202010900115.1A 2020-08-31 2020-08-31 Medicine database access method and device and computer equipment Pending CN112035479A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010900115.1A CN112035479A (en) 2020-08-31 2020-08-31 Medicine database access method and device and computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010900115.1A CN112035479A (en) 2020-08-31 2020-08-31 Medicine database access method and device and computer equipment

Publications (1)

Publication Number Publication Date
CN112035479A true CN112035479A (en) 2020-12-04

Family

ID=73586644

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010900115.1A Pending CN112035479A (en) 2020-08-31 2020-08-31 Medicine database access method and device and computer equipment

Country Status (1)

Country Link
CN (1) CN112035479A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112818019A (en) * 2021-01-29 2021-05-18 北京思特奇信息技术股份有限公司 Query request filtering method applied to Redis client and Redis client
CN113590622A (en) * 2021-07-28 2021-11-02 中国人民银行清算总中心 Distributed data access method and device

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106445944A (en) * 2015-08-06 2017-02-22 阿里巴巴集团控股有限公司 Data query request processing method and apparatus, and electronic device
CN106469225A (en) * 2016-09-28 2017-03-01 厦门嵘拓物联科技有限公司 A kind of method that in intelligent workshop management, magnanimity manufaturing data accesses
CN107943991A (en) * 2017-12-01 2018-04-20 成都嗨翻屋文化传播有限公司 A kind of distributed reptile frame and implementation method based on memory database
US20180191750A1 (en) * 2016-12-30 2018-07-05 Capital One Services, Llc Systems and methods for detecting resources responsible for events
CN108780458A (en) * 2017-12-08 2018-11-09 深圳市大疆创新科技有限公司 A kind of page cache processing method, device and server
CN110489405A (en) * 2019-07-12 2019-11-22 平安科技(深圳)有限公司 The method, apparatus and server of data processing
CN110569233A (en) * 2019-06-30 2019-12-13 华为技术有限公司 Hot data management method, device and system

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106445944A (en) * 2015-08-06 2017-02-22 阿里巴巴集团控股有限公司 Data query request processing method and apparatus, and electronic device
CN106469225A (en) * 2016-09-28 2017-03-01 厦门嵘拓物联科技有限公司 A kind of method that in intelligent workshop management, magnanimity manufaturing data accesses
US20180191750A1 (en) * 2016-12-30 2018-07-05 Capital One Services, Llc Systems and methods for detecting resources responsible for events
CN107943991A (en) * 2017-12-01 2018-04-20 成都嗨翻屋文化传播有限公司 A kind of distributed reptile frame and implementation method based on memory database
CN108780458A (en) * 2017-12-08 2018-11-09 深圳市大疆创新科技有限公司 A kind of page cache processing method, device and server
CN110569233A (en) * 2019-06-30 2019-12-13 华为技术有限公司 Hot data management method, device and system
CN110489405A (en) * 2019-07-12 2019-11-22 平安科技(深圳)有限公司 The method, apparatus and server of data processing

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
刘淑平 等: "基于Bloom filter降低云数据库网络延时的影响", 《软件导刊》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112818019A (en) * 2021-01-29 2021-05-18 北京思特奇信息技术股份有限公司 Query request filtering method applied to Redis client and Redis client
CN112818019B (en) * 2021-01-29 2024-02-02 北京思特奇信息技术股份有限公司 Query request filtering method applied to Redis client and Redis client
CN113590622A (en) * 2021-07-28 2021-11-02 中国人民银行清算总中心 Distributed data access method and device

Similar Documents

Publication Publication Date Title
KR102545615B1 (en) Data synchronization method and apparatus, computer device and readable storage medium
CN109634925B (en) Resource file downloading method, device, computer equipment and storage medium
CN110866198B (en) Static resource caching method, system, device, computer equipment and storage medium
US7546370B1 (en) Search engine with multiple crawlers sharing cookies
CN111125169B (en) Data query method, control device, control medium and computer equipment
CN112035479A (en) Medicine database access method and device and computer equipment
CN109413153B (en) Data crawling method and device, computer equipment and storage medium
KR101400680B1 (en) System of automatically collecting malignant code
CN112165461A (en) Zero-trust dynamic authorization method and device and computer equipment
CN111597422A (en) Buried point mapping method and device, computer equipment and storage medium
JP2002108671A (en) Method and system for providing customized information in computer processing system
CN109670100B (en) Page data capturing method and device
US20170244714A1 (en) Method for providing browser using browser processes separated for respective access privileges and apparatus using the same
CN114629875B (en) Active detection domain name brand protection method and device
CN114827271A (en) Multi-level cache online control method and related device
CN114610973A (en) Information search matching method and device, computer equipment and storage medium
KR20180083800A (en) Monitoring system and method for detect changes in web page by comparing tree structures
CN115017538A (en) Data processing method and device, electronic equipment and storage medium
WO2008029146A1 (en) A distributed file system operable with a plurality of different operating systems
CN112153011A (en) Detection method and device for machine scanning, electronic equipment and storage medium
CN111090470A (en) Secure starting method and device of cloud host, computer equipment and storage medium
CN117170823B (en) Method and device for executing operation in batch container and electronic equipment
CN113127321B (en) Data reading method, device and equipment based on Jmeter and storage medium
CN112631769B (en) Local cache management method, device, equipment and medium for APP
CN116304458B (en) Method, device, equipment and medium for web page real-time notification update

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20220525

Address after: 518000 China Aviation Center 2901, No. 1018, Huafu Road, Huahang community, Huaqiang North Street, Futian District, Shenzhen, Guangdong Province

Applicant after: Shenzhen Ping An medical and Health Technology Service Co.,Ltd.

Address before: Room 12G, Block H, 666 Beijing East Road, Huangpu District, Shanghai 200000

Applicant before: PING AN MEDICAL AND HEALTHCARE MANAGEMENT Co.,Ltd.

RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20201204