CN112948363A - Data processing method and device, electronic equipment and storage medium - Google Patents

Data processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN112948363A
CN112948363A CN202110151856.9A CN202110151856A CN112948363A CN 112948363 A CN112948363 A CN 112948363A CN 202110151856 A CN202110151856 A CN 202110151856A CN 112948363 A CN112948363 A CN 112948363A
Authority
CN
China
Prior art keywords
time point
expiration time
data
data object
ordered structure
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
CN202110151856.9A
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.)
Beijing Kingsoft Cloud Network Technology Co Ltd
Original Assignee
Beijing Kingsoft Cloud Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Cloud Network Technology Co Ltd filed Critical Beijing Kingsoft Cloud Network Technology Co Ltd
Priority to CN202110151856.9A priority Critical patent/CN112948363A/en
Publication of CN112948363A publication Critical patent/CN112948363A/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/21Design, administration or maintenance of databases
    • G06F16/215Improving data quality; Data cleansing, e.g. de-duplication, removing invalid entries or correcting typographical errors
    • 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/23Updating
    • G06F16/235Update request formulation
    • 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/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2474Sequence data queries, e.g. querying versioned data
    • 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/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5022Mechanisms to release resources

Abstract

The application discloses a data processing method and device, electronic equipment and a storage medium. The data processing method comprises the following steps: traversing an ordered structure, and determining a target expiration time point meeting the current time, wherein the ordered structure comprises the expiration time point stored in a key value pair form and an object identifier corresponding to the expiration time point; determining a first object identifier corresponding to the target expiration time point based on the ordered structure; querying a data object corresponding to the first object identification and a first data structure corresponding to the data object; a delete operation is performed on the first data structure. According to the embodiment of the application, the expiration time and the object identification of the data object are stored in the ordered structure, so that the efficiency of inquiring the data object can be effectively improved when the data object is eliminated. Compared with the prior art that the expired data objects are filtered by adopting a Hash algorithm, the hit rate of the data objects is improved, and the situations of random hit and insufficient elimination quantity can be avoided.

Description

Data processing method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of database technologies, and in particular, to a data processing method and apparatus, an electronic device, and a storage medium.
Background
In the prior art, an expiration elimination algorithm of a redis database generally adopts a hash structure to store data objects and expiration times of the data objects. When obsolete data objects are eliminated, firstly, a hash function is adopted to calculate the identification of the data objects to obtain a hash value, then the hash value is subjected to remainder in a hash groove according to the length of a list in the groove to obtain a calculation result, finally, whether the expiry time corresponding to the data objects exceeds the current time is checked according to the calculation result, and if the expiry time exceeds the current time according to the check result, the data structure corresponding to the data objects is deleted.
In the process of implementing the present application, the inventor finds that the hash structure belongs to an unordered data structure. Based on the data structure, when the outdated elimination algorithm is adopted to eliminate the data objects, the outdated data objects can not be eliminated timely and quickly, and meanwhile, the problem that a part of data objects can not be covered in the elimination process also exists.
When the data volume in the redis database is large, a plurality of data objects which are expired and not deleted in time exist, so that the blockage of the redis database is easily caused, and the normal use of the redis database is influenced.
Disclosure of Invention
In order to solve the technical problems described above or at least partially solve the technical problems, the present application provides a data processing method, an apparatus, an electronic device, and a storage medium.
According to an aspect of an embodiment of the present application, there is provided a data processing method, including;
traversing an ordered structure, and determining a target expiration time point meeting the current time, wherein the ordered structure comprises the expiration time point stored in a key value pair form and an object identifier corresponding to the expiration time point;
determining a first object identifier corresponding to the target expiration time point based on the ordered structure;
querying a data object corresponding to the first object identification and a first data structure corresponding to the data object;
a delete operation is performed on the first data structure.
Further, the traversing the ordered structure to determine a target expiration time point that satisfies the current time includes:
acquiring current time;
traversing the ordered structure to determine a minimum expiration time point;
when the minimum expiration time point is less than or equal to a current time, an expiration time point in the ordered structure that is between the minimum expiration time point and the current time is identified as the target expiration time point.
Further, the method further comprises:
determining a time difference between the minimum expiration time point and the current time when the minimum expiration time point is greater than the current time;
determining the residual survival time of the data object corresponding to the minimum expiration time point according to the time difference;
and when the residual survival time meets a preset condition, determining a second object identifier corresponding to the minimum expiration time point based on the ordered structure, and adding the second object identifier to a monitoring queue.
Further, the method further comprises:
receiving a data updating request, wherein the data updating request carries a third object identifier and a new expiration time point;
determining a third data object corresponding to the third object identifier and an original expiration time point of the third data object;
and deleting the original expiration time point from the ordered structure, and writing the third object identifier and the newly-added expiration time point into the ordered structure.
Further, the writing the third object identifier into the ordered structure corresponding to the new expiration time point includes:
determining order information of the new expiration time points in the ordered structure;
and writing the newly added expiration time point and the third object identifier into the ordered structure according to the sequence information.
Further, the method further comprises:
acquiring a first memory utilization rate of the database;
when the first memory usage rate is greater than a preset usage rate, acquiring an expiration time point set matched with the current detection period from the ordered structure and a first object identification set corresponding to the expiration time point set;
inquiring a first data object set corresponding to the first object identification set and the occupied memory of each data object in the first data object set;
determining a data object occupying a memory larger than a preset memory in the first data object set as a fourth data object;
and executing deletion operation on the data structure corresponding to the fourth data object.
Further, the method further comprises:
after the deletion operation is executed on the data structure corresponding to the fourth data object, acquiring a second memory utilization rate of the database;
traversing the data object with the expiration time point as the preset value in the data structure when the second memory utilization rate is still greater than the preset utilization rate;
and deleting the data structure corresponding to the data object with the expiration time point as the preset value.
According to another aspect of the embodiments of the present application, there is also provided a data processing apparatus, including:
the traversal module is used for traversing an ordered structure and determining a target expiration time point meeting the current time, wherein the ordered structure comprises the expiration time point stored in a key value pair form and an object identifier corresponding to the expiration time point;
a determining module, configured to determine, based on the ordered structure, a first object identifier corresponding to the target expiration time point;
the query module is used for querying a data object corresponding to the first object identifier and a first data structure corresponding to the data object;
and the deleting module is used for executing deleting operation on the first data structure.
According to another aspect of the embodiments of the present application, there is also provided a storage medium including a stored program that executes the above steps when the program is executed.
According to another aspect of the embodiments of the present application, there is also provided an electronic apparatus, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus; wherein: a memory for storing a computer program; a processor for executing the steps of the method by running the program stored in the memory.
Embodiments of the present application also provide a computer program product containing instructions, which when run on a computer, cause the computer to perform the steps of the above method.
Compared with the prior art, the technical scheme provided by the embodiment of the application has the following advantages: according to the embodiment of the application, the expiration time and the object identification of the data object are stored in the ordered structure, so that the efficiency of inquiring the data object is effectively improved when the data object is eliminated. Compared with the prior art that the expired data objects are filtered by adopting a Hash algorithm, the hit rate of the data objects is improved, and the situations of random hit and insufficient elimination quantity can be avoided.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and together with the description, serve to explain the principles of the application.
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, and it is obvious for those skilled in the art to obtain other drawings without inventive exercise.
Fig. 1 is a flowchart of a data processing method according to an embodiment of the present application;
fig. 2 is a flowchart of a data processing method according to another embodiment of the present application;
fig. 3 is a flowchart of a data processing method according to another embodiment of the present application;
fig. 4 is a block diagram of a data processing apparatus according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely with reference to the drawings in the embodiments of the present application, it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments, and the illustrative embodiments and descriptions thereof of the present application are used for explaining the present application and do not constitute a limitation to the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another similar entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, 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 an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The embodiment of the application provides a data processing method and device, electronic equipment and a storage medium. The method provided by the embodiment of the invention can be applied to any required electronic equipment, for example, the electronic equipment can be electronic equipment such as a server and a terminal, and the method is not particularly limited herein, and is hereinafter simply referred to as electronic equipment for convenience in description.
According to an aspect of embodiments of the present application, there is provided an embodiment of a method for data processing. Fig. 1 is a flowchart of a data processing method according to an embodiment of the present application, and as shown in fig. 1, the method includes:
step S11, traversing the ordered structure to determine the target expiration time point meeting the current time, wherein the ordered structure comprises the expiration time point stored in a key value pair form and the object identification corresponding to the expiration time point;
in the embodiment of the application, a data structure of each data object in a database is firstly queried, an expiration time point of the data object is determined from the data structure of each data object, the expiration time point and an object identifier corresponding to the data object are added to an ordered structure, and the ordered structure is stored in a key-value pair form, wherein the expiration time point is a key name (key), and the object identifier is a key value (value).
In this embodiment of the present application, the database is a redis database, where multiple different data objects are stored in the redis database, and the data objects may be: string objects (string objects), hash objects (hash objects), list objects (list objects), set objects (set objects), and ordered set objects (zset objects), among others. The ordered structure may be a binary tree structure or an rax tree structure, and is not particularly limited herein.
It should be noted that each data object in the redis database has its corresponding data structure (redisObject), and the parameter of the data object can be read from the data structure, and in addition, the data structure in the embodiment of the present application is compared with the parameter of the new expiration time point in the existing data structure. The data structure in the prior art is as follows:
typedef struct redisObject{
// data type
unsigned type:4;
// data encoding
unsigned encoding:4;
// points to the underlying data
unsigned lru:REDIS_LRU_BITS;
/*lru time(relative to server.lruclock)*/
// reference count
int refcount;
// pointer to actual value
Void*prt;
}robj;
In the embodiment of the application, the data structure of the data object is improved, and the expiration time point is added in the data structure, so that the efficiency of inquiring the expired data object can be improved, and a basis is provided for subsequently deleting the expired data object. The improved data structure of the data object is as follows:
typedef struct redisObject{
// data type
unsigned type:4;
// data encoding
unsigned encoding:4;
// points to the underlying data
unsigned lru:REDIS_LRU_BITS;
/*lru time(relative to server.lruclock)*/
// reference count
int refcount;
// time to expiration
long long expiretime
// pointer to actual value
Void*prt;
}robj;
In the embodiment of the present application, step S11, traversing the ordered structure to determine the target expiration time point satisfying the current time includes the following steps a 1-A3:
step A1, acquiring the current time;
step A2, traversing the ordered structure to determine a minimum expiration time point;
in this embodiment of the present application, traversing the data structure to obtain the time set may be to traverse the data structures of all data objects in the database by a preset time period, so as to obtain an expiration time point set. The set of expiration time points includes the expiration time of each data object. For example: an expiration time T1 of a string object (string object), an expiration time T2 of a hash object (hash object), an expiration time T3 of a list object (list object), and an expiration time T4 of a set object (set object), and the like.
Step a3, when the minimum expiration time point is less than or equal to the current time, identifying an expiration time point in the ordered structure that is between the minimum expiration time point and the current time as a target expiration time point.
In the embodiment of the present application, when the minimum expiration time point is smaller than the current time, an expiration time point between the minimum expiration time point and the current time is obtained from the ordered structure, and the expiration time point is determined as the target expiration time point. And when the minimum expiration time point is equal to the current time, confirming the minimum expiration time point as the target expiration time point.
As an example, the expiration time T1 of string (string object), the expiration time T2 of hash (hash object), the expiration time T3 of list (list object), and the expiration time T4 of set (set object) are sorted, and the obtained sorting result is: t4 ═ T2 < T1 < T3. Wherein T4 and T2 are minimum expiration time points, and when T4 or T2 is smaller than the current time, the size of T1 and the current time is determined. If T1 is greater than T, then T4 and T2 are target expiration time points. If T3 is less than T, then T1, T2, T3, and T4 are target expiration time points.
Step S12, determining a first object identifier corresponding to the target expiration time point based on the ordered structure;
in the embodiment of the application, because the corresponding relationship between the expiration time and the object identifier is stored in the ordered structure, after the target expiration time point is obtained, the key name matched with the target expiration time point is determined from the ordered structure, the key value corresponding to the key name is read, and the object identifier displayed on the key value is used as the first object identifier.
Step S13, querying a data object corresponding to the first object identifier and a first data structure corresponding to the data object;
in the embodiment of the present application, a data object corresponding to the first object identifier and a first data structure corresponding to the data object are queried from a redis database.
In step S14, a delete operation is performed on the first data structure.
According to the embodiment of the application, the expiration time and the object identification of the data object are stored in the ordered structure, so that the efficiency of inquiring the data object is effectively improved when the data object is eliminated. Compared with the prior art that the expired data objects are filtered by adopting a Hash algorithm, the hit rate of the data objects is improved, and the situations of random hit and insufficient elimination quantity can be avoided.
The method provided by the embodiment of the application further comprises the following steps B1-B3:
step B1, when the minimum expiration time point is larger than the current time, determining the time difference between the minimum expiration time point and the current time;
in the embodiment of the present application, when the minimum expiration point is greater than the current time, it indicates that there is no expired data object in the database, and at this time, the time difference is obtained by subtracting the current time from the minimum expiration point.
Step B2, determining the residual survival time of the data object corresponding to the minimum expiration time point according to the time difference;
in this embodiment of the application, the obtained time difference is used as the minimum expiration time point to correspond to the remaining lifetime of the data object, and as can be understood, the remaining lifetime is the storage time of the data object in the database.
And step B3, when the remaining survival time meets the preset condition, determining a second object identifier corresponding to the minimum expiration time point based on the ordered structure, and adding the second object identifier to the monitoring queue.
In the embodiment of the present application, the condition that the remaining lifetime satisfies the preset condition includes: the remaining lifetime is less than the preset lifetime. The monitoring queue is used for monitoring the data objects with the residual survival time meeting the preset conditions.
In the embodiment of the application, the monitoring queue is used for monitoring the data object to be expired, so that the expiration time can be timely deleted when the expiration time is reached, and the stable operation of the database can be ensured.
In the embodiment of the present application, before the deletion operation is performed on the first data structure, the following steps C1-C3 are further included:
step C1, determining the usage information of the first object identification corresponding to the data object according to the first data structure;
in the embodiment of the present application, the usage information includes the number of references of the data object and the last access time.
Step C2, when the usage information satisfies the preset delay strategy, determining the extension time of the data object corresponding to the first object identifier according to the usage information;
in the embodiment of the present application, the using information satisfying the preset delay policy includes: the reference times are more than or equal to the preset reference times in the preset time length, or the time difference between the last access time interval and the current time is less than or equal to the preset time difference.
In an embodiment of the present application, determining the extension time of the data object corresponding to the first object identifier according to the usage information includes: acquiring a corresponding relationship between the preset use information and the preset extension time, for example: within the preset time length of 2min, the preset reference times are 10 times, and the corresponding extension time is 5 min.
Step C3, updating the target expiration time point according to the extension time;
step C4, when the updated target expiration time point is reached, a delete operation is performed on the first data structure.
In the embodiment of the application, before deleting the data structure corresponding to the data object, the use information of the data object is confirmed, and whether the expiration time point is prolonged or not is determined through the use information, so that the normal use of the database can be ensured.
Fig. 2 is a flowchart of a data processing method according to an embodiment of the present application, and as shown in fig. 2, the method may include the following steps:
step S21, receiving a data updating request, wherein the data updating request carries a third object identifier and a new increment expiration time point;
in the embodiment of the application, the data updating request may be initiated by the client actively, or may be generated according to a triggering operation of the user, and the data updating request carries the object identifier and the new expiration time point.
As an example, the user may execute an exit command on a data object having an expiration time, where the exit command carries a new expiration time, and the new expiration time is used to replace an old expiration time corresponding to the data object.
Step S22, determining a third data object corresponding to the third object identifier and an original expiration time point of the third data object;
in the embodiment of the application, after receiving the data update request, the third data object corresponding to the object identifier and the data structure of the third data object are acquired. Determining parameters of a third data object from the data structure, the parameter information comprising: inner encoding, data object last access time, reference count, expiration time point, etc. Thus, the original expiration time point of the third data object is obtained after obtaining the corresponding parameters.
In the embodiment of the present application, the process of obtaining the original expiration time point is as follows: the expiration time point stored in the data structure is first queried, and when the expiration time point is 0, this indicates that the data object has reached the expiration time point, and is deleted. When the expiration time point is not 0, this indicates that the data object has not reached the expiration time point, and this time point is taken as the original expiration time point.
And step S23, deleting the original expiration time point from the ordered structure, and writing the third object identifier and the newly-added expiration time point into the ordered structure.
In this embodiment of the application, the step S23, writing the third object identifier into the ordered structure corresponding to the new expiration time point, includes the following steps C1-C2:
step C1, determining the order information of the newly-added expiration time points in the ordered structure;
in the embodiment of the application, other expiration time points in the ordered structure are traversed first, and the size sequence of the other expiration time points is determined, so that the sequence information of the newly-added expiration time points in the ordered structure is determined.
And step C2, writing the new expiration time point and the third object identifier into the ordered structure according to the sequence information.
In the embodiment of the application, the target position of the new past due time point in the ordered structure is determined according to the sequence information, then the new past due time point is used as the key name, and the third object identification is used as the key value and written into the target position in the ordered structure.
In the process of implementing the present application, the inventor further finds that, when the data volume is suddenly increased, the memory of redis is still full of the data objects in the lifetime, and when the memory occupied by a single data object is too large, redis blocking may be caused, and the consumption is severe, so that the redis database cannot be normally used. To this end, the present application provides a data processing method, and fig. 3 is a flowchart of a data processing method provided in an embodiment of the present application, and as shown in fig. 3, the method may include the following steps:
step S31, obtaining a first memory usage rate of the database;
in the embodiment of the application, the memory usage rate of the redis database is checked according to a preset period, when the memory usage rate of the redis is greater than a preset threshold, a deletion program for a data object is started to be executed, the memory is cleared and released, and when the memory usage rate is less than or equal to the preset threshold, the deletion program for the data object is not executed or the deletion program is stopped. The memory usage threshold is an allowable maximum value of a percentage of the used memory in the total memory, the threshold is a percentage, and may be set according to an actual requirement, for example, the threshold is set to 95%, when the used memory is greater than 95% of the total memory of the redis database, the deletion operation is executed, the redis memory is cleared and released, and if the used memory is less than or equal to 95% of the total memory of the redis database, the deletion operation is not executed or is stopped.
Step S32, when the first memory usage rate is larger than the preset usage rate, obtaining an expiration time point set matched with the current detection period and a first object identification set corresponding to the expiration time point set from the ordered structure;
in the embodiment of the application, when the memory usage rate is greater than the preset usage rate, the current detection period and the expiration time point belonging to the current detection period are determined. For example: and 11:00-11:10 is a current detection period, then obtaining expiration time points belonging to 11:00-11:10 from the ordered structure, adding the expiration time points to an expiration time point set, and then obtaining a first object identification set corresponding to the expiration time point set from the ordered structure.
Step S33, querying a first data object set corresponding to the first object identifier set, and memory occupied by each data object in the first data object set;
in the embodiment of the application, a data object corresponding to each object identifier in the first object identifier set is queried and added to the first data object set, and the memory occupied by each data object is determined during adding.
Step S34, determining a data object occupying a memory larger than a preset memory in the first data object set as a fourth data object;
in this embodiment of the present application, the occupied memory of each data object in the first data object set is compared with the preset memory, and a data object whose occupied memory is greater than the preset memory is determined as the fourth data object.
In step S35, a delete operation is performed on the data structure corresponding to the fourth data object.
In the embodiment of the application, the data objects occupying the memory larger than the preset memory are deleted, so that the memory space is released, and the memory utilization rate of the database is ensured.
The method provided by the embodiment of the application further comprises the following steps E1-E3:
step E1, after the deletion operation is performed on the data structure corresponding to the fourth data object, acquiring a second memory usage rate of the database;
step E2, when the second memory usage rate is still greater than the preset usage rate, traversing the data object whose expiration time point is the preset value in the data structure;
in the embodiment of the present application, the preset value may be 0. By traversing the data object whose expiration time point is 0 in the data structure, the data object that has expired at this time can be deleted.
And E3, deleting the data structure corresponding to the data object with the expiration time point as the preset value.
According to the memory occupation, the life cycle and the limited duration of the object model of the redis database, the health check timing task of the redis database is combined, when the redis database is to be fully loaded, a large memory key with the life cycle and a large memory key without the life cycle are set to be overdue automatically, the two algorithms are combined, whether the memory space meets the requirement is checked when every 1 key is deleted, and the deletion is immediately terminated when the requirement is met. Through the execution of the two algorithms, the memory space of the redis database is effectively released, and the stable operation of the database is ensured.
Fig. 4 is a block diagram of a data processing apparatus provided in an embodiment of the present application, which may be implemented as part of or all of an electronic device through software, hardware, or a combination of the two. As shown in fig. 4, the apparatus includes:
a traversing module 41, configured to traverse an ordered structure, and determine a target expiration time point that meets the current time, where the ordered structure includes an expiration time point stored in a key-value pair form and an object identifier corresponding to the expiration time point;
a determining module 42, configured to determine, based on the ordered structure, a first object identifier corresponding to the target expiration time point;
a query module 43, configured to query a data object corresponding to the first object identifier and a first data structure corresponding to the data object;
a delete module 44 for performing a delete operation on the first data structure.
In the embodiment of the application, the traversal module is used for acquiring the current time; traversing the ordered structure to determine a minimum expiration time point; and when the minimum expiration time point is less than or equal to the current time, confirming an expiration time point between the minimum expiration time point and the current time in the ordered structure as a target expiration time point.
In an embodiment of the present application, the apparatus further includes: the monitoring module is used for determining the time difference between the minimum expiration time point and the current time when the minimum expiration time point is greater than the current time; determining the residual survival time of the data object corresponding to the minimum expiration time point according to the time difference; and when the residual survival time meets the preset condition, determining a second object identifier corresponding to the minimum expiration time point based on the ordered structure, and adding the second object identifier to the monitoring queue.
In this embodiment, the apparatus further includes an update module, where the update module includes:
the receiving submodule is used for receiving a data updating request, and the data updating request carries a third object identifier and a new expiration time point;
the determining submodule is used for determining a third data object corresponding to the third object identifier and an original expiration time point of the third data object;
and the execution submodule is used for deleting the original expiration time point from the ordered structure and writing the third object identifier and the newly-added expiration time point into the ordered structure.
In the embodiment of the application, the execution submodule is used for determining the sequence information of the newly-increased expiration time point in the ordered structure; and writing the newly-increased expiration time point and the third object identification into the ordered structure according to the sequence information.
In the embodiment of the application, the device further comprises a processing module, a first memory usage rate obtaining module, a second memory usage rate obtaining module and a second memory usage rate obtaining module, wherein the processing module is used for obtaining the first memory usage rate of the database; when the first memory utilization rate is greater than the preset utilization rate, acquiring an expiration time point set matched with the current detection period and a first object identification set corresponding to the expiration time point set from the ordered structure; inquiring a first data object set corresponding to the first object identification set and the occupied memory of each data object in the first data object set; determining a data object occupying a memory larger than a preset memory in the first data object set as a fourth data object; and executing deletion operation on the data structure corresponding to the fourth data object.
In this embodiment of the application, the processing module is configured to obtain a second memory usage rate of the database after executing a deletion operation on a data structure corresponding to the fourth data object; when the second memory utilization rate is still greater than the preset utilization rate, traversing the data object with the expiration time point as the preset value in the data structure; and deleting the data structure corresponding to the data object with the expiration time point as the preset value.
An embodiment of the present application further provides an electronic device, as shown in fig. 5, the electronic device may include: the system comprises a processor 1501, a communication interface 1502, a memory 1503 and a communication bus 1504, wherein the processor 1501, the communication interface 1502 and the memory 1503 complete communication with each other through the communication bus 1504.
A memory 1503 for storing a computer program;
the processor 1501 is configured to implement the steps of the above embodiments when executing the computer program stored in the memory 1503.
The communication bus mentioned in the above terminal may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the terminal and other equipment.
The Memory may include a Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the Integrated Circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component.
In yet another embodiment provided by the present application, a computer-readable storage medium is further provided, which has instructions stored therein, and when the instructions are executed on a computer, the instructions cause the computer to execute the data processing method described in any of the above embodiments.
In yet another embodiment provided by the present application, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform the data processing method of any of the above embodiments.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the application to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wire (e.g., coaxial cable, fiber optic, digital subscriber line) or wirelessly (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk), among others.
The above description is only for the preferred embodiment of the present application, and is not intended to limit the scope of the present application. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application are included in the protection scope of the present application.
The above description is merely exemplary of the present application and is presented to enable those skilled in the art to understand and practice the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A data processing method, comprising:
traversing an ordered structure, and determining a target expiration time point meeting the current time, wherein the ordered structure comprises the expiration time point stored in a key value pair form and an object identifier corresponding to the expiration time point;
determining a first object identifier corresponding to the target expiration time point based on the ordered structure;
querying a data object corresponding to the first object identification and a first data structure corresponding to the data object;
a delete operation is performed on the first data structure.
2. The method of claim 1, wherein traversing the ordered structure to determine a target expiration time point that satisfies a current time comprises:
acquiring current time;
traversing the ordered structure to determine a minimum expiration time point;
when the minimum expiration time point is less than or equal to a current time, an expiration time point in the ordered structure that is between the minimum expiration time point and the current time is identified as the target expiration time point.
3. The method of claim 2, further comprising:
determining a time difference between the minimum expiration time point and the current time when the minimum expiration time point is greater than the current time;
determining the residual survival time of the data object corresponding to the minimum expiration time point according to the time difference;
and when the residual survival time meets a preset condition, determining a second object identifier corresponding to the minimum expiration time point based on the ordered structure, and adding the second object identifier to a monitoring queue.
4. The method of claim 1, further comprising:
receiving a data updating request, wherein the data updating request carries a third object identifier and a new expiration time point;
determining a third data object corresponding to the third object identifier and an original expiration time point of the third data object;
and deleting the original expiration time point from the ordered structure, and writing the third object identifier and the newly-added expiration time point into the ordered structure.
5. The method of claim 4, wherein said writing the third object identifier to the ordered structure corresponding to the new expiration time point comprises:
determining order information of the new expiration time points in the ordered structure;
and writing the newly added expiration time point and the third object identifier into the ordered structure according to the sequence information.
6. The method of claim 1, further comprising:
acquiring a first memory utilization rate of the database;
when the first memory usage rate is greater than a preset usage rate, acquiring an expiration time point set matched with the current detection period from the ordered structure and a first object identification set corresponding to the expiration time point set;
inquiring a first data object set corresponding to the first object identification set and the occupied memory of each data object in the first data object set;
determining a data object occupying a memory larger than a preset memory in the first data object set as a fourth data object;
and executing deletion operation on the data structure corresponding to the fourth data object.
7. The method of claim 6, further comprising:
after the deletion operation is executed on the data structure corresponding to the fourth data object, acquiring a second memory utilization rate of the database;
traversing the data object with the expiration time point as the preset value in the data structure when the second memory utilization rate is still greater than the preset utilization rate;
and deleting the data structure corresponding to the data object with the expiration time point as the preset value.
8. A data processing apparatus, comprising:
the traversal module is used for traversing an ordered structure and determining a target expiration time point meeting the current time, wherein the ordered structure comprises the expiration time point stored in a key value pair form and an object identifier corresponding to the expiration time point;
a determining module, configured to determine, based on the ordered structure, a first object identifier corresponding to the target expiration time point;
the query module is used for querying a data object corresponding to the first object identifier and a first data structure corresponding to the data object;
and the deleting module is used for executing deleting operation on the first data structure.
9. A storage medium, characterized in that the storage medium comprises a stored program, wherein the program is operative to perform the method steps of any of the preceding claims 1 to 7.
10. An electronic device comprising a processor, a communication interface, a memory and a communication bus,
the processor, the communication interface and the memory complete mutual communication through a communication bus;
wherein:
a memory for storing a computer program;
a processor for performing the method steps of any of claims 1-7 by executing a program stored on a memory.
CN202110151856.9A 2021-02-03 2021-02-03 Data processing method and device, electronic equipment and storage medium Pending CN112948363A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110151856.9A CN112948363A (en) 2021-02-03 2021-02-03 Data processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110151856.9A CN112948363A (en) 2021-02-03 2021-02-03 Data processing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112948363A true CN112948363A (en) 2021-06-11

Family

ID=76243555

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110151856.9A Pending CN112948363A (en) 2021-02-03 2021-02-03 Data processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112948363A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110187836A (en) * 2019-05-29 2019-08-30 北京奇艺世纪科技有限公司 A kind of data-erasure method, device, computer and storage medium
CN113792058A (en) * 2021-08-09 2021-12-14 北京达佳互联信息技术有限公司 Index data processing method and device, electronic equipment and storage medium

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110187836A (en) * 2019-05-29 2019-08-30 北京奇艺世纪科技有限公司 A kind of data-erasure method, device, computer and storage medium
CN110187836B (en) * 2019-05-29 2022-09-02 北京奇艺世纪科技有限公司 Data deleting method and device, computer and storage medium
CN113792058A (en) * 2021-08-09 2021-12-14 北京达佳互联信息技术有限公司 Index data processing method and device, electronic equipment and storage medium
CN113792058B (en) * 2021-08-09 2023-10-24 北京达佳互联信息技术有限公司 Index data processing method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN112948363A (en) Data processing method and device, electronic equipment and storage medium
CN106294206B (en) Cache data processing method and device
CN113805805B (en) Method and device for eliminating cache memory block and electronic equipment
CN110489405B (en) Data processing method, device and server
CN109086141B (en) Memory management method and device and computer readable storage medium
CN111198856A (en) File management method and device, computer equipment and storage medium
CN111782707A (en) Data query method and system
CN112000281A (en) Caching method, system and device for deduplication metadata of storage system
CN112416972A (en) Real-time data stream processing method, device, equipment and readable storage medium
CN109144431B (en) Data block caching method, device, equipment and storage medium
CN112463058B (en) Fragmented data sorting method and device and storage node
US11853229B2 (en) Method and apparatus for updating cached information, device, and medium
CN111221468B (en) Storage block data deleting method and device, electronic equipment and cloud storage system
CN113268439A (en) Memory address searching method and device, electronic equipment and storage medium
CN106354793B (en) Method and device for monitoring hot spot object
CN110888846B (en) Data memory management method and system
CN114528231A (en) Data dynamic storage method and device, electronic equipment and storage medium
US20060149891A1 (en) Relocated reclaim block
CN111651443A (en) Data management method and device, electronic equipment and storage medium
CN107870925B (en) Character string filtering method and related device
CN114896082A (en) Message processing method and device, electronic equipment and storage medium
CN116820323A (en) Data storage method, device, electronic equipment and computer readable storage medium
CN110333968B (en) Data management method and device applied to database and computer equipment
CN113760854A (en) Method for identifying data in HDFS memory and related equipment
CN114764416A (en) Data caching method, device and equipment and computer readable storage medium

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