CN120804160A - Cache data query method and device, electronic equipment and readable storage medium - Google Patents
Cache data query method and device, electronic equipment and readable storage mediumInfo
- Publication number
- CN120804160A CN120804160A CN202510932627.9A CN202510932627A CN120804160A CN 120804160 A CN120804160 A CN 120804160A CN 202510932627 A CN202510932627 A CN 202510932627A CN 120804160 A CN120804160 A CN 120804160A
- Authority
- CN
- China
- Prior art keywords
- task
- queried
- result
- value
- hash
- 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
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2455—Query execution
- G06F16/24552—Database cache management
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/22—Indexing; Data structures therefor; Storage structures
- G06F16/2228—Indexing structures
- G06F16/2255—Hash tables
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Computational Linguistics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses a cache data query method, a device, electronic equipment and a readable storage medium, which relate to the technical field of information technology and are used for solving the problem of low cache data query efficiency. The method comprises the steps of obtaining a task identifier of a task to be queried, calculating the task identifier by using a hash function to obtain a hash value, searching elements in a bit array based on the hash value to obtain a target element, and extracting the result of the task to be queried from a cache database under the condition that the value of the target element represents that the result of the task to be queried is in a cached state. The embodiment of the invention can improve the query efficiency of the cache data.
Description
Technical Field
The present invention relates to the field of information technology (Information Technology, IT) technologies, and in particular, to a method, an apparatus, an electronic device, and a readable storage medium for querying cache data.
Background
In the prior art, a cache Key (Key) is generally constructed according to service parameters, and a cache database is queried based on the cache Key. The intelligent center platform is a center platform integrating data capacity, artificial intelligence (ARTIFICIAL INTELLIGENCE, AI) algorithm capacity and business service capacity and is used for supporting the rapid development and operation of various intelligent businesses of enterprises.
Because of the huge number of tasks processed by the intelligent middle station, the conventional cache data query method in the prior art can obviously reduce the query efficiency when processing large-scale tasks.
Disclosure of Invention
The embodiment of the invention provides a cache data query method, a device, electronic equipment and a readable storage medium, which are used for solving the problem of low cache data query efficiency.
In a first aspect, an embodiment of the present invention provides a method for querying cached data, including:
Acquiring a task identifier of a task to be queried;
Calculating the task identifier by using a hash function to obtain a hash value;
searching elements in the bit array based on the hash value to obtain a target element;
And under the condition that the value of the target element represents that the result of the task to be queried is in a cached state, extracting the result of the task to be queried from a cache database.
Optionally, the number of the hash functions is a plurality, and different hash functions are used for determining different target elements;
And extracting the result of the task to be queried from a cache database under the condition that the value of the target element represents that the result of the task to be queried is in a cached state, wherein the method comprises the following steps:
And under the condition that the values of all the target elements represent that the results of the task to be queried are in a cached state, extracting the results of the task to be queried from a cache database.
Optionally, before the task identifier is calculated by using a hash function to obtain a hash value, the method further includes:
The method comprises the steps of adjusting the number of hash functions based on the density of a bit array, wherein the density is determined based on the ratio of the target number to the size of the bit array, the target number is the number of elements with first values in the bit array, and the first values are used for representing that the results of tasks corresponding to the elements are cached;
Resetting the bit array according to a preset strategy, and setting the values of all elements in the bit array to be second values, wherein the second values are used for representing that the results of the tasks corresponding to the elements are in an uncached state.
Optionally, the adjusting the number of hash functions based on the density of the bit array includes:
Increasing the number of hash functions if the density is greater than a first preset value;
And reducing the number of the hash functions under the condition that the density is smaller than a second preset value.
Optionally, after the target element is obtained by searching in the elements of the bit array based on the hash value, the method further includes:
acquiring the result of the task to be queried under the condition that the value of the target element represents that the result of the task to be queried is in an uncached state;
Storing the result of the task to be queried into the cache database;
And adjusting the value of the target element so that the value of the target element characterizes the result of the task to be queried as a cached state.
Optionally, the obtaining the result of the task to be queried includes:
calculating the task to be queried to obtain a result of the task to be queried;
or, initiating a query request to a database, and determining the result of the task to be queried based on the query result, wherein the query result is the result returned by the database based on the query request.
Optionally, before the task identifier of the task to be queried is obtained, the method further includes:
receiving a task request sent by a request end, wherein the task request carries task information of a target task;
and splitting the target task into a plurality of tasks to be queried based on the task information.
In a second aspect, an embodiment of the present invention further provides a cached data query device, including:
The first acquisition module is used for acquiring a task identifier of a task to be queried;
the calculation module is used for calculating the task identifier by using a hash function to obtain a hash value;
the searching module is used for searching elements in the bit array based on the hash value to obtain target elements;
and the extraction module is used for extracting the result of the task to be queried from a cache database under the condition that the value of the target element represents that the result of the task to be queried is in a cached state.
In a third aspect, an embodiment of the present invention further provides an electronic device, including a memory, a processor, and a program stored on the memory and executable on the processor;
The processor is configured to read a program in a memory to implement the steps in the cache data query method according to the first aspect.
In a fourth aspect, embodiments of the present invention further provide a readable storage medium storing a program, where the program when executed by a processor implements the steps of the cache data querying method according to the first aspect.
In the embodiment of the invention, a task identifier of a task to be queried is firstly obtained, then a hash function is used for calculating the task identifier to obtain a hash value, elements in a bit array are searched based on the hash value to obtain a target element, and finally the result of the task to be queried is extracted from a cache database under the condition that the value of the target element represents that the result of the task to be queried is in a cached state. The embodiment provides an efficient cache query mechanism, and can realize the rapid positioning of massive task results through the combination of the bit array and the hash function, thereby improving the cache query efficiency.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings that are needed in the description of the embodiments of the present invention will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort to a person of ordinary skill in the art.
FIG. 1 is a flowchart of a method for querying cache data according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a cache data query system according to an embodiment of the present invention;
FIG. 3 is a block diagram of a cache data query device according to an embodiment of the present invention;
Fig. 4 is a block diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In the embodiment of the application, the term "and/or" describes the association relation of the association objects, which means that three relations can exist, for example, A and/or B, and can mean that A exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the context-dependent object is an "or" relationship. The term "plurality" in embodiments of the present application means two or more, and other adjectives are similar. The terms first, second and the like in the description and in the claims, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the terms so used are interchangeable under appropriate circumstances such that the embodiments of the application are capable of operation in sequences other than those illustrated or otherwise described herein, and that the "first" and "second" distinguishing between objects generally are not limited in number to the extent that the first object may, for example, be one or more.
First, several terms involved in the present application will be described:
Bit Array (Bit Array) a data structure for saving space and efficiently representing boolean values (0/1) for efficiently storing and manipulating Bit-level data. As a specific bit array, the bit array is a one-dimensional array composed of binary bits (bits), and each element can be only 0 or 1.
Hash Function (Hash Function), a Function that converts an input of arbitrary length (such as a string, a file, a number, etc.) into an output value of fixed length (called a Hash value or Hash value), a process also called Hashing.
Based on the above, the embodiment of the application provides a cache data query method, a device, an electronic device and a readable storage medium, aiming at improving the query efficiency of cache data. As shown in fig. 1, the method for querying the cached data specifically includes the following steps:
Step 101, acquiring a task identifier of a task to be queried.
It should be appreciated that the task identity is unique and is capable of uniquely determining the task to be queried and its results. In particular, the specific format of the task identifier is not limited herein. As an alternative embodiment, the task identification is determined based on at least one of the name of the task to be queried, the number of the task to be queried, and a combination of parameters of the task to be queried.
In some embodiments, after extracting the task identifier from the task to be queried, the task identifier needs to be preprocessed so that the task identifier meets the input requirement of the hash function. Specifically, preprocessing the task identifier includes format conversion, deduplication, and the like.
Optionally, in some embodiments, before the step 101, the method further includes:
receiving a task request sent by a request end, wherein the task request carries task information of a target task;
and splitting the target task into a plurality of tasks to be queried based on the task information.
The method provided by the embodiment of the application can be executed by the server. As a specific embodiment, the server side includes a task control module, where the task control module is configured to receive a task request sent by the request side.
In a specific implementation, a user sends a task request through a request end. Specifically, the user may choose to initiate the task request via a client (e.g., an Application (APP) or web platform). For scenarios that require integration into third party systems or automation flows, the user may also initiate a task request through an application programming interface (Application Programming Interface, API) interface.
It should be appreciated that the task information includes task types and/or task parameters. After receiving the task request, the server verifies the task information, specifically, verifies the task parameters to ensure that the parameters are complete, legal and in accordance with the business rules.
As an alternative embodiment, the task request also carries authentication information. In this embodiment, before verifying the task information, the server first verifies the authentication information to ensure that the task request is from a legitimate user or an authorized system. Specifically, the specific manner of verifying the authentication information is not limited herein. For example, the authentication method may be a user name password authentication method, an oauth2.0 authorization method, or an API key authentication method.
In some embodiments, the server parses the task request, extracts key information and requirements based on task information, determines complexity of a target task and a data type to be processed according to a task type, splits the target task into a plurality of subtasks based on the complexity of the target task and the data type, each subtask includes a data segment and a logic processing unit required for execution, and each subtask serves as a task to be queried.
Specifically, the server evaluates whether the target task can be decomposed into a plurality of subtasks according to the complexity of the target task and the data volume to be processed, and considers the logic structure, the data dependency relationship and the possibility of parallel processing of the target task. Under the condition that the target task can be split, a task splitting strategy is formulated, the sub-tasks after splitting can be confirmed to be independently executed, and the execution results can be combined to obtain a final task result. Specifically, the task decomposition policy includes granularity of decomposition, division manner of subtasks, dependency relationship among subtasks, and the like.
In some embodiments, when splitting a target task into a plurality of tasks to be queried based on task information, a task identification for each task to be queried may be generated based on task decomposition-related logic processing.
In contrast to the situation that the related data of the task and the service are cached based on the whole task, in this embodiment, a task is split into a plurality of subtasks, and each subtask is used as a task to be queried to query. By the method, the granularity of the cache is reduced, and the method can be better suitable for business environments with high complexity and large difference, such as intelligent center desks.
And 102, calculating the task identifier by using a hash function to obtain a hash value.
In this embodiment, the hash function is used to calculate the task identifier, so as to obtain a hash value, where the hash value is a numerical value or a binary string, and is used to locate the cache location in the bit array of the result of the task to be queried. Specifically, the number of hash functions is not limited herein, and each hash function may calculate a hash value.
Optionally, in some embodiments, the number of hash functions is a plurality, the number of hash functions is determined based on the size of the bit array, and different hash functions are used to determine different target elements.
In this embodiment, the number of hash functions is plural, and by using a plurality of different hash functions, a plurality of different hash values can be calculated. Wherein the number of hash functions is determined based on the size of the bit array, typically the number of hash functions is positively correlated with the size of the bit array.
It should be appreciated that the size of the array of bits is predetermined based on the traffic requirements and the size of the cache data, and that the size of the array of bits should be large enough to accommodate all possible cache entry identifications while also taking into account the efficiency of memory usage. In particular implementations, the server or cache system needs to allocate sufficient memory space for the bit number allocation to ensure that the allocated memory space is contiguous to improve access efficiency.
In specific implementation, the number of hash functions and the parameters of the hash functions are determined during initialization, and appropriate parameters, such as seed values, coefficients and the like, are set for each hash function to ensure the diversity and independence of the hash functions. The hash function should have good distribution and collision resistance to ensure that the task identity can be mapped uniformly into the bit array.
In this embodiment, on one hand, by using multiple hash functions, the probability that multiple task identifiers are calculated to obtain the same hash value may be reduced, so that hash collision (hash) is reduced, which improves the efficiency of searching and inserting the data structure. On the other hand, the plurality of hash functions can effectively disperse data, map a task identifier to a plurality of hash values, and greatly reduce the misjudgment rate (False Positive Rate).
And step 103, searching elements in the bit array based on the hash value to obtain a target element.
In this embodiment, the bit array is checked based on the hash value, and a corresponding element of the hash value in the bit array is obtained, where the element is a target element, and is used to record whether the result of the task to be queried is cached. As a specific embodiment, the target element has a value including two cases, the first case where the target element has a first value (e.g., 1) that is used to represent the cached state of the task represented by the element, and the second case where the target element has a second value (e.g., 0) that is used to represent the uncached state of the task represented by the element.
It should be understood that in the embodiment where the number of hash functions is plural, the number of hash values calculated is also plural, and a target element may be found based on each hash value. In this embodiment, the number of target elements is plural.
Step 104, extracting the result of the task to be queried from a cache database under the condition that the value of the target element represents that the result of the task to be queried is in a cached state.
It should be understood that the cache database is used for temporarily storing the execution results of the subtasks, so as to facilitate efficient execution of the subsequent tasks. Under the condition that the value of the target element represents that the result of the task to be queried is in a cached state, the result of the task to be queried can be directly extracted from the cache database without repeatedly executing the task to be queried, thereby realizing the rapid multiplexing of the task and improving the processing efficiency of the task.
Optionally, in the case that the number of hash functions is plural, the step 104 includes:
And under the condition that the values of all the target elements represent that the results of the task to be queried are in a cached state, extracting the results of the task to be queried from a cache database.
In embodiments where the number of hash functions is multiple, multiple target elements may be queried. In this embodiment, when the values of all the target elements obtained by querying represent that the result of the task to be queried is in a cached state, the result of the task to be queried is considered to be cached, the result of the task to be queried is extracted from the cache database, otherwise, the result of the task to be queried is considered to be not cached. By the method, the accuracy of the query result can be improved, and misexistence and misjudgment are avoided.
Optionally, in some embodiments, after the step 103, the method further includes:
acquiring the result of the task to be queried under the condition that the value of the target element represents that the result of the task to be queried is in an uncached state;
Storing the result of the task to be queried into the cache database;
And adjusting the value of the target element so that the value of the target element characterizes the result of the task to be queried as a cached state.
It should be understood that, in the case where the result of the task to be queried is not cached, the result of the task to be queried cannot be obtained from the cache database. At this time, according to the requirement of the task to be queried, whether the result of the task to be queried is obtained directly through calculation or the result of the task to be queried is obtained by querying a database is judged.
Optionally, in some embodiments, the obtaining the result of the task to be queried includes:
and calculating the task to be queried to obtain a result of the task to be queried.
Under the condition that the task to be queried involves complex data processing or algorithm calculation, the calculation is directly carried out on the server side, and the result of the task to be queried is obtained. Specifically, for the task needing to be calculated, a corresponding algorithm or logic processing unit is called for calculation. In specific implementation, whether to directly calculate at the server side can be judged based on the data amount to be processed and a calculation algorithm to be adopted.
Optionally, in some embodiments, the obtaining the result of the task to be queried includes:
after the result of the task to be queried is obtained through calculation or query, a query request is initiated to a database, the result of the task to be queried is determined based on the query result, and the query result is returned by the database based on the query request. The database is used for storing the subtask calculation result in a lasting mode.
In a specific implementation, the required data is not queried in the cache database, and whether a query request needs to be initiated to the database can be judged according to the data source of the data required by the definition task and the data dependency relationship identified when the subtasks are divided.
Under the condition that the task to be queried depends on data stored in a database, a query request is initiated to the database, after a query result is obtained, the result of the task to be queried is determined based on the query result, wherein whether the query result is further processed to obtain the result of the task to be queried is mainly determined by service logic of the task to be queried. Specifically, for tasks requiring querying the database, a structured query statement (Structured Query Language, SQL) or other query command is constructed, a request is initiated to the database, and the query result is obtained.
It should be understood that after obtaining the query result or the result of the task to be queried, the query result or the result of the task to be queried may be verified, and the correctness and the integrity of the result may be determined. In some embodiments, the result is a string of data, the integrity of which and consistency with the original data is ensured by computing the MD5 check value of the data.
It should be understood that the results of the task to be queried may be stored in a cache database according to a preset cache policy. Illustratively, an appropriate caching policy is selected based on traffic requirements and data characteristics, such as least recently Used (LEAST RECENTLY Used, LRU) or least frequently Used (Least Frequently Used, LFU).
Specifically, the storage location and format of the cache may be a hash table, a dis cache, etc. in the memory. Specifically, if the hash table in the memory is used, the hash value of the result is calculated according to the hash function, the result is stored in the corresponding hash bucket, and if an external cache system such as Redis is used, the result is written into the cache through the corresponding client library.
After the storage is completed, the value of the corresponding target element is adjusted so that the value of the target element represents that the result of the task to be queried is in a cached state. Illustratively, modifying the value of the target element from 0 to 1 characterizes the cached results for the task to be queried. In the case that the number of hash functions is plural, a plurality of corresponding target elements may be obtained, and in this embodiment, the values of all the target elements need to be adjusted.
In this embodiment, the task to be queried is a subtask obtained by splitting from the target task, and the subtask is convenient to multiplex by storing the results of the task to be queried, so that the data processing efficiency can be effectively improved, the cache space utilization rate can be optimized, the resource consumption of the application service can be further reduced, and the operation cost of the system can be controlled.
Optionally, in some embodiments, before the calculating the task identifier using a hash function to obtain a hash value, the method further includes:
The method comprises the steps of adjusting the number of hash functions based on the density of a bit array, wherein the density is determined based on the ratio of the target number to the size of the bit array, the target number is the number of elements with first values in the bit array, and the first values are used for representing that the results of tasks corresponding to the elements are cached;
Resetting the bit array according to a preset strategy, and setting the values of all elements in the bit array to be second values, wherein the second values are used for representing that the results of the tasks corresponding to the elements are in an uncached state.
It should be understood that, the time for resetting the bit array according to the preset policy may be adjusted and set according to the actual situation, but in order to make the hash value obtained by calculating the task identifier using the hash function accurate, the operation of resetting the bit array needs to be completed before the hash value calculation is performed.
As an optional implementation manner, resetting the bit number set according to a preset policy includes:
When the server is updated or restarted, the bit array is reset, and the emptying operation of the bit array is synchronized with the updating time of the server through the setting, so that the consistency of the cached data can be ensured.
As another alternative embodiment, resetting the bit number set according to a preset policy includes:
And resetting the bit number group according to a preset period. The preset period may be daily, weekly, monthly, etc. The timeliness of the cached data can be ensured by regularly clearing the expired or invalid cache item identifiers in the bit array according to a preset period through a timing task or a trigger.
As another alternative embodiment, resetting the bit number set according to a preset policy includes:
And resetting the bit number set when the load of the server is lower than a preset value. In this embodiment, the load condition of the server is detected, and when the load of the server is lower than the preset value, the bit array is cleared, so that the influence of executing the clearing operation on the performance of the server in the high load can be avoided.
It should be appreciated that the hash function may be reset each time the bit array is cleared, so that the number of hash functions is more reasonable. Optionally, in some embodiments, the adjusting the number of hash functions based on the density of the bit array includes:
Increasing the number of hash functions if the density is greater than a first preset value;
And reducing the number of the hash functions under the condition that the density is smaller than a second preset value.
Specifically, assuming that the size of the bit array is m and the number of elements (i.e., set bits) having the first value is n, the density ρ=n/m of the bit array. The number k of hash functions can be dynamically adjusted according to the density ρ and a preset false positive rate threshold e. As a specific embodiment, the value of k is increased when ρ is greater than the first preset value ρ_max, and the value of k is decreased when ρ is less than the second preset value ρ_min.
In this embodiment, the number of hash functions is dynamically adjusted according to the current density of the bit array (i.e. the proportion of the set bits), and increasing the number of hash functions when the density is too high can reduce the false positive rate, and reducing the number of hash functions when the density is too low can save space. By the method, the cache system can be more flexibly adapted to different application scenes and data characteristics, and the cache efficiency and the space utilization rate are further improved. By the method, the cache system can better process the time-efficiency data, and the proportion of fresh data in the cache is improved.
In the embodiment of the application, a task identifier of a task to be queried is acquired, a hash function is used for calculating the task identifier to obtain a hash value, elements in a bit array are searched based on the hash value to obtain a target element, and the result of the task to be queried is extracted from a cache database under the condition that the value of the target element represents that the result of the task to be queried is in a cached state. The embodiment provides an efficient cache query mechanism, and can realize the rapid positioning of massive subtask results through the combination of the bit array and the hash function, thereby improving the cache query efficiency.
Referring to fig. 2, the embodiment of the invention also provides a cache query system, which comprises a client and a server, wherein the server comprises a task control module, a bit array, a hash function module and a cache database. The request end is used for sending a task request to the service end, and the request end is a middle-platform task or service calling and initiating party when the task is concretely implemented. And the task control module is used for identifying and disassembling the target task according to the type of the task after receiving the request, obtaining the task to be queried, and completing corresponding logic execution according to the task to be queried, the call bit array and the hash function module. And in the task execution process, the cache database is required to be read and written according to the data interaction result. The bit array is used for recording and controlling the mapping relation between tasks and the cache. The hash function module is used for calling a hash function, calculating a hash value and controlling the mapping relation calculation process of the bit array and the task.
Referring to fig. 3, an embodiment of the present invention further provides a cache data query apparatus 300. Fig. 3 is a block diagram of a cache data query device 300 according to an embodiment of the present invention. Since the principle of the cache data query device 300 for solving the problem is similar to that of the cache data query method shown in fig. 1 in the embodiment of the present invention, the implementation of the cache data query device 300 can refer to the implementation of the method, and the repetition is omitted.
As shown in fig. 3, the cache data query device 300 includes:
The first obtaining module 301 is configured to obtain a task identifier of a task to be queried;
the calculating module 302 is configured to calculate the task identifier by using a hash function to obtain a hash value;
a searching module 303, configured to search elements in the bit array based on the hash value to obtain a target element;
And the extracting module 304 is configured to extract the result of the task to be queried from the cache database when the value of the target element characterizes the result of the task to be queried is in a cached state.
Optionally, the number of the hash functions is a plurality, and different hash functions are used for determining different target elements;
The extracting module 304 is specifically configured to:
And under the condition that the values of all the target elements represent that the results of the task to be queried are in a cached state, extracting the results of the task to be queried from a cache database.
Optionally, the cache data query device 300 further includes:
the first adjusting module is used for adjusting the number of the hash functions based on the density of the bit array, wherein the density is determined based on the ratio of the target number to the size of the bit array, the target number is the number of elements with first values in the bit array, and the first values are used for representing that the results of tasks corresponding to the elements are cached states;
And the resetting module is used for resetting the bit array according to a preset strategy, setting the values of all the elements in the bit array to be second values, wherein the second values are used for representing that the results of the tasks corresponding to the elements are in an uncached state.
Optionally, the adjusting module is specifically configured to:
Increasing the number of hash functions if the density is greater than a first preset value;
And reducing the number of the hash functions under the condition that the density is smaller than a second preset value.
Optionally, the method of the cache data query device 300 further includes:
The second acquisition module is used for acquiring the result of the task to be queried under the condition that the value of the target element represents that the result of the task to be queried is in an uncached state;
The storage module is used for storing the result of the task to be queried into the cache database;
and the second adjusting module is used for adjusting the value of the target element so that the value of the target element represents that the result of the task to be queried is in a cached state.
Optionally, the first obtaining module 301 is specifically configured to:
calculating the task to be queried to obtain a result of the task to be queried;
or, initiating a query request to a database, and determining the result of the task to be queried based on the query result, wherein the query result is the result returned by the database based on the query request.
Optionally, the cache data query device 300 further includes:
The receiving module is used for receiving a task request sent by a request end, wherein the task request carries task information of a target task;
and the splitting module is used for splitting the target task into a plurality of tasks to be queried based on the task information.
The cache data query device 300 provided in the embodiment of the present invention may execute the above embodiment of the cache data query method, and its implementation principle and technical effects are similar, and this embodiment will not be repeated here.
In the several embodiments provided in the present application, it should be understood that the disclosed methods and apparatus may be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may be physically included separately, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in hardware plus software functional units.
The integrated units implemented in the form of software functional units described above may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium, and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform part of the steps of the transceiving method according to the embodiments of the present invention. The storage medium includes a U disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, an optical disk, or other various media capable of storing program codes.
As shown in fig. 4, the embodiment of the present invention further provides an electronic device 400, where the electronic device 400 includes a processor 401 for reading a program in a memory 402, and performing the following steps:
Acquiring a task identifier of a task to be queried;
Calculating the task identifier by using a hash function to obtain a hash value;
searching elements in the bit array based on the hash value to obtain a target element;
And under the condition that the value of the target element represents that the result of the task to be queried is in a cached state, extracting the result of the task to be queried from a cache database.
Optionally, the number of the hash functions is a plurality, and different hash functions are used for determining different target elements;
the processor 401 is further configured to read a program in the memory 402, and perform the following steps:
And under the condition that the values of all the target elements represent that the results of the task to be queried are in a cached state, extracting the results of the task to be queried from a cache database.
Optionally, the processor 401 is further configured to read a program in the memory 402, and perform the following steps:
The method comprises the steps of adjusting the number of hash functions based on the density of a bit array, wherein the density is determined based on the ratio of the target number to the size of the bit array, the target number is the number of elements with first values in the bit array, and the first values are used for representing that the results of tasks corresponding to the elements are cached;
Resetting the bit array according to a preset strategy, and setting the values of all elements in the bit array to be second values, wherein the second values are used for representing that the results of the tasks corresponding to the elements are in an uncached state.
Optionally, the processor 401 is further configured to read a program in the memory 402, and perform the following steps:
Increasing the number of hash functions if the density is greater than a first preset value;
And reducing the number of the hash functions under the condition that the density is smaller than a second preset value.
Optionally, the processor 401 is further configured to read a program in the memory 402, and perform the following steps:
acquiring the result of the task to be queried under the condition that the value of the target element represents that the result of the task to be queried is in an uncached state;
Storing the result of the task to be queried into the cache database;
And adjusting the value of the target element so that the value of the target element characterizes the result of the task to be queried as a cached state.
Optionally, the processor 401 is further configured to read a program in the memory 402, and perform the following steps:
calculating the task to be queried to obtain a result of the task to be queried;
or, initiating a query request to a database, and determining the result of the task to be queried based on the query result, wherein the query result is the result returned by the database based on the query request.
Optionally, the processor 401 is further configured to read a program in the memory 402, and perform the following steps:
receiving a task request sent by a request end, wherein the task request carries task information of a target task;
and splitting the target task into a plurality of tasks to be queried based on the task information.
The electronic device 400 provided in the embodiment of the present invention may execute the above embodiment of the cache data query method, and its implementation principle and technical effects are similar, and this embodiment will not be described herein again.
The embodiment of the application also provides a readable storage medium, and the readable storage medium stores a program, which when executed by a processor, realizes the processes of the above embodiment of the cache data query method, and can achieve the same technical effects, so that repetition is avoided, and no further description is provided here.
The readable storage medium may be any available medium or data storage device that can be accessed by a processor, including, but not limited to, magnetic memories (e.g., floppy disks, hard disks, magnetic tapes, magneto-Optical disks (MO), etc.), optical memories (e.g., compact Disks (CD), digital video discs (DIGITAL VERSATILE DISC, DVD), blu-ray discs (BD), high-Definition VERSATILE DISC, HVD, etc.), and semiconductor memories (e.g., read-Only Memory (ROM), erasable programmable Read-Only Memory (Erasable Programmable Read-Only Memory, EPROM), electrically erasable programmable Read-Only Memory (ELECTRICALLY ERASABLE PROGRAMMABLE READ ONLY MEMORY, EEPROM), nonvolatile Memory (NAND FLASH), solid state Disk (Solid STATE DISK or Solid STATE DRIVE, SSD)), etc.
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, method, article, or apparatus 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, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. In light of such understanding, the technical solutions of the present application may be embodied essentially or in part in the form of a software product stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) comprising instructions for causing a terminal (which may be a cell phone, computer, server, air conditioner, or network device, etc.) to perform the methods described in the various embodiments of the present application.
The embodiments of the present application have been described above with reference to the accompanying drawings, but the present application is not limited to the above-described embodiments, which are merely illustrative and not restrictive, and many forms may be made by those having ordinary skill in the art without departing from the spirit of the present application and the scope of the claims, which are to be protected by the present application.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202510932627.9A CN120804160A (en) | 2025-07-07 | 2025-07-07 | Cache data query method and device, electronic equipment and readable storage medium |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202510932627.9A CN120804160A (en) | 2025-07-07 | 2025-07-07 | Cache data query method and device, electronic equipment and readable storage medium |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN120804160A true CN120804160A (en) | 2025-10-17 |
Family
ID=97327545
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202510932627.9A Pending CN120804160A (en) | 2025-07-07 | 2025-07-07 | Cache data query method and device, electronic equipment and readable storage medium |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN120804160A (en) |
-
2025
- 2025-07-07 CN CN202510932627.9A patent/CN120804160A/en active Pending
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US11494403B2 (en) | Method and apparatus for storing off-chain data | |
| CN111880746A (en) | Method and device for writing service data into block chain system | |
| CN115039082B (en) | Log writing method, device, electronic device, and storage medium | |
| US11182378B2 (en) | System and method for committing and rolling back database requests | |
| CN119397166A (en) | A data request processing method, device, equipment and storage medium | |
| US8560572B2 (en) | System for lightweight objects | |
| US9009731B2 (en) | Conversion of lightweight object to a heavyweight object | |
| US9659041B2 (en) | Model for capturing audit trail data with reduced probability of loss of critical data | |
| CN110222046B (en) | List data processing method, device, server and storage medium | |
| CN116954680A (en) | Plug-in updating method, device, equipment, medium and program product of storage system | |
| CN114443583A (en) | Method, device and equipment for arranging fragment space and storage medium | |
| CN120804160A (en) | Cache data query method and device, electronic equipment and readable storage medium | |
| CN111930781B (en) | Method and device for processing data request of cache database | |
| CN117667305A (en) | Service scene-based security policy deployment method and device and electronic equipment | |
| CN120935167B (en) | Asynchronous file generation and download implementation methods and systems | |
| CN118132520B (en) | Storage system file processing method, electronic device, storage medium and program product | |
| KR102727220B1 (en) | Multiple smart contract operation system for stable and efficient blockchain service | |
| CN119106409B (en) | Front-end dynamic data authority binding and verification method, system and readable storage medium | |
| US20250370811A1 (en) | Workload distribution based on node properties | |
| KR102278185B1 (en) | System and method for serverless service using blockchain node | |
| CN120415802A (en) | Data encryption transmission method, device and equipment | |
| CN120215817A (en) | Disk defragmentation method, device, electronic device and storage medium | |
| CN114881606A (en) | Execution method, device, equipment and storage medium of policy modification behavior | |
| CN117217540A (en) | Sample construction methods, devices, equipment, media and program products | |
| CN116112442A (en) | Request-response method, apparatus, computer device, storage medium and program product |
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 |