CN113961743B - Data updating method and device, electronic equipment and storage medium - Google Patents

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

Info

Publication number
CN113961743B
CN113961743B CN202111536561.XA CN202111536561A CN113961743B CN 113961743 B CN113961743 B CN 113961743B CN 202111536561 A CN202111536561 A CN 202111536561A CN 113961743 B CN113961743 B CN 113961743B
Authority
CN
China
Prior art keywords
video object
information
target video
target
database
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111536561.XA
Other languages
Chinese (zh)
Other versions
CN113961743A (en
Inventor
杨芳
孙成新
商帆
王金明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Feihu Information Technology Tianjin Co Ltd
Original Assignee
Feihu Information Technology Tianjin 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 Feihu Information Technology Tianjin Co Ltd filed Critical Feihu Information Technology Tianjin Co Ltd
Priority to CN202111536561.XA priority Critical patent/CN113961743B/en
Publication of CN113961743A publication Critical patent/CN113961743A/en
Application granted granted Critical
Publication of CN113961743B publication Critical patent/CN113961743B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/70Information retrieval; Database structures therefor; File system structures therefor of video data
    • G06F16/73Querying
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a data updating method, a data updating device, electronic equipment and a storage medium, wherein a video object acquisition request sent by a user is received, if a target video object corresponding to target video object information does not exist in a redis cache, the target video object exists in a database, the target video object is updated to the redis cache, and the target video object is fed back to the user; if the video object indicated by the operation updating information sent by the user based on the target video object is inquired from the database, updating the video object information of the video object indicated by the operation updating information in the database by using the operation updating information to obtain updated video object information; updating video object information of a target video object in the redis using the updated video object information; and if the video object indicated by the operation updating information is not inquired from the database and the optimistic lock is abnormal, clearing the target video object in the redis cache and outputting a target optimistic lock abnormal request.

Description

Data updating method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a data updating method and apparatus, an electronic device, and a storage medium.
Background
With the continuous development of internet technology, the usage of the PUGC video service system is more and more extensive. Based on comprehensive consideration of aspects such as use system performance, resource cost, development cost, database and cache consistency and the like, the video object in the PUGC video service system is cached in a redis cache mode, the redis cache is updated when the video object in the database is updated, meanwhile, the key expiration time is set in the redis cache, and the final consistency of the database and the redis cache data is ensured.
However, in the case that the redis cache fails, or the video object in the database is successfully updated and the video object in the redis cache fails to be updated, if the key in the redis cache is not expired, the video object read from the redis cache by the next update operation is inconsistent with the video object in the database, and the dirty data is updated to the database by the user when the operation is updated based on the dirty data acquired from the redis cache, that is, the video object.
Disclosure of Invention
In view of this, the present invention provides a data updating method, an apparatus, an electronic device, and a storage medium, so as to avoid the problem that the dirty data is updated into the database due to the fact that the video object read from the redis cache is inconsistent with the video object of the database.
The invention discloses a data updating method in a first aspect, which comprises the following steps:
when a video object acquisition request sent by a user is received, judging whether a target video object corresponding to target video object information exists in a redis cache, wherein the video object acquisition request at least comprises the target video object information;
if the target video object corresponding to the target video object information does not exist in the redis cache, judging whether the target video object corresponding to the target video object information exists in a database or not;
if the target video object exists in the database, updating the target video object to the redis cache, and feeding the target video object back to the user;
when detecting that the user sends operation updating information based on the target video object, inquiring whether a video object indicated by the operation updating information exists in the database; wherein the video object indicated by the operation update information is the target video object;
if the video object indicated by the operation updating information is inquired from the database, updating the video object information of the video object indicated by the operation updating information in the database by using the operation updating information to obtain updated video object information;
updating video object information of the target video object in the redis using the updated video object information;
if the video object indicated by the operation updating information is not inquired from the database and the optimistic lock is abnormal, emptying the target video object in the redis cache and outputting a target optimistic lock abnormal request, wherein the target optimistic lock abnormal request is the optimistic lock abnormal request aiming at the target video object.
Optionally, the method further includes:
detecting whether the output frequency of the target optimistic lock abnormal request is greater than a preset output threshold value in real time;
if the frequency of outputting the target optimistic lock abnormal request is larger than the preset output threshold value, outputting corresponding alarm information;
and if the frequency of outputting the target optimistic lock abnormal request is not greater than the preset output threshold value, the current video object information of the target video object in the database is used as the target video object information of the target video object request again, and the operation is returned to judge whether the target video object corresponding to the target video object information exists in the redis cache.
Optionally, the video object information includes a target id, and if a target video object does not exist in the redis cache, determining whether the target video object exists in the database includes:
and if the target video object corresponding to the target id does not exist in the redis cache, judging whether the target video object corresponding to the target id exists in a database or not.
Optionally, if the video object indicated by the operation update information is queried from the database, updating the video object information of the video object indicated by the operation update information in the database by using the operation update information to obtain updated video object information, where the method includes:
if the video object indicated by the operation updating information is inquired from the database, updating the video object information of the video object indicated by the operation updating information in the database by using the operation updating information based on preset atomic operation to obtain updated video object information;
wherein updating the video object information of the video object indicated by the operation update information in the database by using the operation update information at least comprises updating the version number of the video object indicated by the operation update information in the database by using the operation update information.
Optionally, the method further includes:
and if the target video object exists in the redis cache, acquiring the target video object from the redis cache, and feeding the target video object back to the user.
Optionally, the method further includes:
and if the target video object does not exist in the database, feeding back an empty video object to the user.
A second aspect of the present invention discloses a data updating apparatus, comprising:
the device comprises a first judging unit, a second judging unit and a third judging unit, wherein the first judging unit is used for judging whether a target video object corresponding to target video object information exists in a redis cache when a video object acquisition request sent by a user is received, and the video object acquisition request at least comprises the target video object information;
a second determining unit, configured to determine whether a target video object corresponding to the target video object information exists in a database if the target video object corresponding to the target video object information does not exist in the redis cache;
a feedback unit, configured to update the target video object to the redis cache and feed the target video object back to the user if the target video object exists in the database;
the query unit is used for querying whether the database has a video object indicated by the operation updating information when the operation updating information sent by the user based on the target video object is detected; wherein the video object indicated by the operation update information is the target video object;
a first updating unit, configured to update video object information of the target video object in the database to obtain updated video object information if a video object indicated by the operation update information is queried from the database;
a second updating unit, configured to update video object information of the target video object in the redis with the video object information;
and the exception request output unit is used for clearing the target video object in the redis cache and outputting a target optimistic lock exception request if the video object indicated by the operation updating information is not inquired from the database and the optimistic lock is abnormal, wherein the target optimistic lock exception request is an optimistic lock exception request aiming at the target video object.
Optionally, the apparatus further comprises:
the real-time detection unit is used for detecting whether the output frequency of the target optimistic lock abnormal request is greater than a preset output threshold value or not in real time;
the alarm information output unit is used for outputting corresponding alarm information if the frequency of outputting the target optimistic lock abnormal request is greater than the preset output threshold;
and the re-determining unit is used for re-using the current video object request of the target video object in the database as the target video object request if the frequency of outputting the target optimistic lock abnormal request is not greater than the preset output threshold value, and returning to execute the first judging unit.
In a third aspect, the present invention discloses an electronic device, which includes a processor and a memory, wherein the memory is used for storing program codes and data for data update, and the processor is used for calling program instructions in the memory to execute a data update method as disclosed in the first aspect of the present invention.
A fourth aspect of the present invention discloses a storage medium, which includes a storage program, wherein when the program runs, a device on which the storage medium is located is controlled to execute the data updating method disclosed in the first aspect of the present invention.
The invention provides a data updating method, a data updating device, electronic equipment and a storage medium, wherein when a video object acquisition request sent by a user is received, whether a target video object corresponding to target video object information exists in a redis cache is judged; if the target video object corresponding to the target video object information does not exist in the redis cache, judging whether the target video object corresponding to the target video object information exists in the database or not; if the target video object exists in the database, updating the target video object into a redis cache, and feeding the target video object back to the user; when detecting that the user sends operation updating information based on the target video object, inquiring whether a database has the video object indicated by the operation updating information; if the video object indicated by the operation updating information is inquired from the database, updating the video object information of the video object indicated by the operation updating information in the database by using the operation updating information to obtain updated video object information; updating video object information of a target video object in the redis by using the video object information; if the video object indicated by the operation updating information is not inquired from the database, and the target video object is failed to be updated, the optimistic lock is abnormal, the target video object in the redis cache is cleared, and a target optimistic lock abnormal request is output, wherein the target optimistic lock abnormal request is an optimistic lock abnormal request for the target video object. According to the technical scheme provided by the invention, under the condition that the target video object requested by the user exists in the database, the target video object is updated into the redis cache, so that when the user requests the target video object again, the target video object can be directly obtained from the redis cache, the hit rate of the redis cache is improved, and the pressure of the database is relieved; however, when the user fails to update the target video object in the database and the optimistic lock is abnormal, it indicates that the target video object stored in the database has changed at this time, and in order to avoid that the target video object obtained by the user from the redis cache is inconsistent with the target video object stored in the database and dirty data is updated into the database, the target video object in the redis cache may be cleared, and a corresponding abnormal request is output, so that a new target video object is returned to the user again based on the output abnormal request and the target video object in the redis cache is updated again.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
FIG. 1 is a flow chart illustrating a data updating method according to an embodiment of the present invention;
FIG. 2 is a schematic structural diagram of a data update apparatus according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. 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 invention.
In this application, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another 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.
redis caching: refers to a cache component or service separate from an application, which is itself an independent application, isolated from the local application, and multiple applications can directly share the cache. The disadvantages are that: since the local node is a separate application, the local node needs to communicate with the local node, and if the cache service crashes, all the dependent nodes can be affected by the network.
PUGC video: and uploading videos and non-copyright videos by the user.
A dubbo interface: the dubbo (open source distributed service framework) is a high-performance excellent service framework of the open source of the Alababa company, so that the application can realize the output and input functions of the service through high-performance RPC and can be seamlessly integrated with the Spring framework.
QPS: all known as Query Per Second, Query rate, is a measure of how much traffic a particular Query server is handling within a specified time.
An optimistic lock: the optimistic lock is particularly optimistic as the name implies, and considers that the resource taken by the lock is not locked because the resource is not operated by other threads, and only judges whether the data is modified or not when the lock is inserted into a database, so that the lock is mainly used for updating data scenes concurrently.
A database: a repository of data, which is an organized, shareable collection of data that is stored long term within a computer. The most common database models are mainly two types, namely, relational database (SQL) and non-relational database (NoSQL, Not Only SQL), and the present invention uses relational database.
apollo: apollo (Apollo) is a distributed configuration center developed by a portable framework department, can be used for centralized management of configurations of different environments and different clusters, can be pushed to an application end in real time after configuration modification, has the characteristics of standard authority, flow control and the like, and is suitable for a micro-service configuration management scene.
Referring to fig. 1, a schematic flow chart of a data updating method provided by an embodiment of the present invention is shown, where the data updating method specifically includes the following steps:
s101: and receiving a video object acquisition request sent by a user.
Wherein the video object acquisition request includes target video object information.
S102: judging whether a target video object corresponding to the target video object information exists in the redis cache or not; if the target video object exists in the redis cache, executing step S103; if the target video object does not exist in the redis cache, step S104 is executed.
In the embodiment of the application, for each video object, the id and the version number corresponding to the video object are preset.
In the process of specifically executing step S102, after receiving a video object acquisition request sent by a user, an upstream service call dubbo interface is called, and it is determined whether a target video object corresponding to a target id indicated by target video object information in the video object acquisition request exists in a redis cache. If yes, executing step S103; if not, step S104 is performed.
It should be noted that the id of each video object is unique.
S103: and acquiring the target video object from the redis cache, and feeding the target video object back to the user.
In the specific process of executing step S103, when it is determined that the target video object corresponding to the target id exists in the redis cache, the target video object is obtained from the redis cache, and the target video object is fed back to the user.
In the embodiment of the present application, after step S103 is performed, step S106 is performed.
S104: judging whether a target video object corresponding to the target video object information exists in the database or not; if the target video object exists in the database, executing step S105; if the target video object does not exist in the database, step S114 is executed.
In the specific execution process of step S104, under the condition that it is determined that the target video object corresponding to the target id does not exist in the redis cache, further determining whether a target video object corresponding to the target id exists in the database, and returning an empty video object to the user if the target video object corresponding to the target id does not exist in the database; if the target video object corresponding to the target id exists in the database, step S105 is performed.
S105: and updating the target video object into a redis cache, and feeding the target video object back to the user.
In the specific execution process of step S105, if it is determined that the target video object corresponding to the target id exists in the database, the target video object corresponding to the target id is acquired from the database, and the target video object is fed back to the user.
In the embodiment of the application, after the target video object corresponding to the target id is obtained, the target video object is updated to the redis cache, so that when a user requests the target video object again, the target video object can be directly obtained from the redis cache, the hit rate of the redis cache is improved, and the pressure of a database is relieved.
S106: when detecting operation updating information sent by a user based on a target video object, inquiring whether a database has the video object indicated by the operation updating information; if the video object indicated by the operation update information is queried from the database, executing step S107; if the video object indicated by the operation update information is not queried from the database, S109 is performed.
In the specific process of executing step S106, after the target video object is fed back to the user, that is, the target video object is displayed to the user, the user may perform a corresponding update operation according to the displayed target video object, that is, send corresponding operation update information, and when the operation update information sent by the user is detected, query whether a video object indicated by the operation update information exists in the database. Specifically, it may be determined whether a video object corresponding to the id and the version number indicated by the operation update information exists in the database, that is, whether the version number of the target video object in the database is the same as the version number of the target video object indicated by the operation update information is determined, and if so, the video object information of the video object indicated by the operation update information in the database is updated by using the operation update information to obtain updated video object information, and it is determined that the target video object in the database is updated successfully; step S107 is executed; if the version numbers of the target video objects in the database are different, it is determined that the target video objects in the database have failed to be updated, and step S109 is executed.
The operation update information at least includes a target id of the target video object, a version number of the target video object, an operation that the target video object is to be updated, and the like.
It should be noted that the operation that wants to update the target video object may be an attribute, a title, and the like of the target video object.
Optionally, an atomicity operation is preset, whether the version number of the target video object in the database is the same as the version number of the target video object indicated by the operation update information is judged based on the preset atomicity operation, if so, the video object information of the video object indicated by the operation update information in the database is further updated by using the operation update information to obtain updated video object information, and it is determined that the target video object in the database is updated successfully.
It should be noted that the preset atomic program may be update video in info set xx1= a first preset value, xx2= a second preset value, and version = version +1 where id = a third preset value and version = a fourth preset value. Wherein id is used for indicating the target id of the target video object, version is used for indicating the target version number of the target video object, xx is used for indicating the operation of updating the target video object, and version +1 is used for indicating that 1 is added to the version number of the target video object under the condition of successful updating.
It should be noted that the first preset value, the second preset value, the third preset value, and the fourth preset value may be determined according to the received operation update information.
In the embodiment of the present application, if the target video object in the database has been operation updated before checking the operation update information sent by the user on the target video object, the version number of the target video object in the database may be changed. At this time, if the operation update information of the target video object sent by the user is detected again, if the target video object indicated by the operation update information cannot be inquired from the database, the update of the target video object in the database may be considered to be failed.
S107: and updating the video object information of the video object indicated by the operation updating information in the database by using the operation updating information to obtain updated video object information.
In the specific execution process of step S107, based on the preset atomicity operation, the video object information of the video object indicated by the operation update information in the database is updated by using the operation update information, so as to obtain updated video object information.
It should be noted that, updating the video object information of the video object indicated by the operation update information in the database by using the operation update information at least includes updating the version number of the video object indicated by the operation update information in the database by using the operation update information, that is, adding a preset numerical value to the version number of the target video object in the database according to the operation update information by using a preset atomic operation, so as to obtain updated video object information. Wherein the preset value may be 1.
In the case where the video object indicated by the operation update information is found in the database, the video object indicated by the operation update information is the target video object.
S108: and updating the video object information of the target video object in the redis by using the updated video object information.
In the process of specifically executing step S108, after the video object information of the target video object in the database is updated to obtain the updated video object information, the video object information of the target video object in the redis is updated by using the updated video object information.
It should be noted that the updated video object information at least includes id, version number of the updated target video object, and corresponding operation update information.
S109: detecting whether the optimistic lock is abnormal or not; if the optimistic lock is abnormal, go to step S110.
In the specific execution process of step S109, in a case where the video object indicated by the operation update information is not queried from the database based on the preset atomicity operation, that is, in a case where the update of the target video object in the database fails based on the preset atomicity operation, it may be determined whether the optimistic lock is abnormal, and if the optimistic lock is abnormal, the target video object in the redis cache is cleared, and a target optimistic lock abnormality request is output.
And if the optimistic lock is not abnormal, ending the data updating process.
It should be noted that the optimistic lock involved in the embodiment of the present invention is an optimistic lock of JPA version.
S110: and clearing the target video object in the redis cache and outputting the target frequent request.
And the target optimistic lock exception request is an optimistic lock exception request aiming at the target video object.
S111: detecting whether the output frequency of the target optimistic lock abnormal request is greater than a preset output threshold value in real time; if the number of times of outputting the target optimistic lock abnormal request is not greater than the preset output threshold, executing the step S112; if the number of times of outputting the target optimistic lock exception request is greater than the preset output threshold, step S113 is executed.
In the specific process of executing step S111, a corresponding output threshold is preset, and the output threshold may be configured in apollo according to specific situations.
After detecting the output target optimistic lock abnormal request, detecting whether the output frequency of the target optimistic lock abnormal request is greater than a preset output threshold value in real time, and if the output frequency of the target optimistic lock abnormal request is not greater than the preset output threshold value, executing step S112; if the number of times of outputting the target optimistic lock exception request is greater than the preset output threshold, step S113 is performed.
S112: and the current video object information of the target video object in the database is used as the target video object information requested by the target video object again.
In the specific process of executing step S112, when it is determined that the number of times of outputting the target optimistic lock abnormal request is not greater than the preset output threshold, the current video object information of the target video object in the database is used again as the target video object information requested by the target video object, and the data updating process of the present application is executed again, that is, after step S112 is executed, the process returns to execute step S102.
S113: and outputting corresponding alarm information.
In the embodiment of the application, under the condition that the number of times of outputting the target optimistic lock abnormal request is determined to be greater than the preset output threshold, corresponding alarm information is output so as to inform technicians that a target video object in the current redis cache is inconsistent with a target video object in the database, and the technicians are instructed to perform corresponding processing to avoid updating dirty data into the database.
S114: the empty video object is fed back to the user.
The invention provides a data updating method, which comprises the steps of judging whether a target video object corresponding to target video object information exists in a redis cache or not when a video object acquisition request sent by a user is received; if the target video object corresponding to the target video object information does not exist in the redis cache, judging whether the target video object corresponding to the target video object information exists in the database or not; if the target video object exists in the database, updating the target video object into a redis cache, and feeding the target video object back to the user; when detecting that the user sends operation updating information based on the target video object, inquiring whether a database has the video object indicated by the operation updating information; if the video object indicated by the operation updating information is inquired from the database, updating the video object information of the video object indicated by the operation updating information in the database by using the operation updating information to obtain updated video object information; updating video object information of a target video object in the redis by using the video object information; and if the video object indicated by the operation updating information is not inquired from the database, and the target video object is failed to be updated, the optimistic lock is abnormal, the target video object in the redis cache is cleared, and a target optimistic lock abnormal request is output, wherein the target optimistic lock abnormal request is an optimistic lock abnormal request aiming at the target video object. According to the technical scheme provided by the invention, under the condition that the target video object requested by the user exists in the database, the target video object is updated into the redis cache, so that when the user requests the target video object again, the target video object can be directly obtained from the redis cache, the hit rate of the redis cache is improved, and the pressure of the database is relieved; however, when the user fails to update the target video object in the database and the optimistic lock is abnormal, it indicates that the target video object stored in the database has changed at this time, and in order to avoid that the target video object obtained by the user from the redis cache is inconsistent with the target video object stored in the database and dirty data is updated into the database, the target video object in the redis cache may be cleared, and a corresponding abnormal request is output, so that a new target video object is returned to the user again based on the output abnormal request and the target video object in the redis cache is updated again.
Corresponding to the data updating method disclosed in the embodiment of the present invention, an embodiment of the present invention further provides a data updating apparatus, as shown in fig. 2, the apparatus includes:
a first determining unit 21, configured to determine whether a target video object corresponding to target video object information exists in a redis cache when a video object acquisition request sent by a user is received, where the video object acquisition request at least includes the target video object information;
a second determining unit 22, configured to determine whether a target video object corresponding to the target video object information exists in the database if the target video object corresponding to the target video object information does not exist in the redis cache;
the first feedback unit 23 is configured to, if a target video object exists in the database, update the target video object to a redis cache, and feed the target video object back to the user;
an inquiring unit 24, configured to, when detecting operation update information sent by a user based on a target video object, inquire whether a video object indicated by the operation update information exists in the database; the video object indicated by the operation updating information is a target video object;
a first updating unit 25, configured to update, if a video object indicated by the operation update information is queried from the database, video object information of the video object indicated by the operation update information in the database by using the operation update information, so as to obtain updated video object information;
a second updating unit 26 for updating video object information of a target video object in the redis with the video object information;
and the exception request output unit 27 is configured to, if the video object indicated by the operation update information is not queried from the database and the optimistic lock is abnormal, clear the target video object in the redis cache and output a target optimistic lock exception request, where the target optimistic lock exception request is an optimistic lock exception request for the target video object.
The specific principle and the implementation process of each unit in the data updating apparatus disclosed in the embodiment of the present invention are the same as those of the data updating method disclosed in fig. 1 in the embodiment of the present invention, and reference may be made to corresponding parts in the data updating method disclosed in fig. 1 in the embodiment of the present invention, and details are not repeated here.
The invention provides a data updating device, which judges whether a target video object corresponding to target video object information exists in a redis cache when receiving a video object acquisition request sent by a user; if the target video object corresponding to the target video object information does not exist in the redis cache, judging whether the target video object corresponding to the target video object information exists in the database or not; if the target video object exists in the database, updating the target video object into a redis cache, and feeding the target video object back to the user; when detecting that the user sends operation updating information based on the target video object, inquiring whether a database has the video object indicated by the operation updating information; if the video object indicated by the operation updating information is inquired from the database, updating the video object information of the video object indicated by the operation updating information in the database by using the operation updating information to obtain updated video object information; updating video object information of a target video object in the redis by using the video object information; and if the video object indicated by the operation updating information is not inquired from the database, and the target video object is failed to be updated, the optimistic lock is abnormal, the target video object in the redis cache is cleared, and a target optimistic lock abnormal request is output, wherein the target optimistic lock abnormal request is an optimistic lock abnormal request for the target video object. According to the technical scheme provided by the invention, under the condition that the target video object requested by the user exists in the database, the target video object is updated into the redis cache, so that when the user requests the target video object again, the target video object can be directly obtained from the redis cache, the hit rate of the redis cache is improved, and the pressure of the database is relieved; however, when the user fails to update the target video object in the database and the optimistic lock is abnormal, it indicates that the target video object stored in the database has changed at this time, and in order to avoid that the target video object obtained by the user from the redis cache is inconsistent with the target video object stored in the database and dirty data is updated into the database, the target video object in the redis cache may be cleared, and a corresponding abnormal request is output, so that a new target video object is returned to the user again based on the output abnormal request and the target video object in the redis cache is updated again.
Optionally, the data updating apparatus disclosed in the present invention further includes:
the real-time detection unit is used for detecting whether the output frequency of the target optimistic lock abnormal request is greater than a preset output threshold value or not in real time;
the alarm information output unit is used for outputting corresponding alarm information if the frequency of outputting the target optimistic lock abnormal request is greater than a preset output threshold;
and the re-determining unit is used for re-taking the current video object request of the target video object in the database as the target video object request and returning to the execution of the first judging unit if the frequency of outputting the target optimistic lock abnormal request is not greater than the preset output threshold value.
Optionally, the second determining unit includes:
and the second judging subunit is used for judging whether the target video object corresponding to the target id exists in the database or not if the target video object corresponding to the target id does not exist in the redis cache.
Optionally, the first updating unit includes:
the first updating subunit is used for updating the video object information of the video object indicated by the operation updating information in the database by using the operation updating information based on preset atomicity operation if the video object indicated by the operation updating information is inquired from the database, so as to obtain updated video object information;
wherein, updating the video object information of the video object indicated by the operation update information in the database by using the operation update information at least comprises updating the version number of the video object indicated by the operation update information in the database by using the operation update information.
Optionally, the data updating apparatus disclosed in the present invention further includes:
and the second feedback unit is used for acquiring the target video object from the redis cache if the target video object exists in the redis cache and feeding the target video object back to the user.
Optionally, the data updating apparatus disclosed in the present invention further includes:
and the third feedback unit is used for feeding back the empty video object to the user if the target video object does not exist in the database.
An embodiment of the present application further provides an electronic device, which includes: the system comprises a processor and a memory, wherein the processor and the memory are connected through a communication bus; the processor is used for calling and executing the program stored in the memory; the memory is used for storing a program for implementing the data updating method.
Referring now to FIG. 3, a block diagram of an electronic device suitable for use in implementing the disclosed embodiments of the invention is shown. The electronic devices in the disclosed embodiments of the present invention may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and the like, and fixed terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 3 is only an example, and should not bring any limitations to the function and scope of use of the disclosed embodiments of the present invention.
As shown in fig. 3, the electronic device may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 301 that may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 302 or a program loaded from a storage device 308 into a Random Access Memory (RAM) 303. In the RAM 303, various programs and data necessary for the operation of the electronic apparatus are also stored. The processing device 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An input/output (I/O) interface 305 is also connected to bus 304.
Generally, the following devices may be connected to the I/O interface 305: input devices 306 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 307 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage devices 308 including, for example, magnetic tape, hard disk, etc.; and a communication device 309. The communication means 309 may allow the electronic device to communicate wirelessly or by wire with other devices to exchange data. While fig. 3 illustrates an electronic device having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flowchart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication means 309, or installed from the storage means 308, or installed from the ROM 302. The computer program, when executed by the processing device 301, performs the above-described functions defined in the methods of the disclosed embodiments of the invention.
Furthermore, an embodiment of the present invention further provides a computer-readable storage medium, where computer-executable instructions are stored in the computer-readable storage medium, and the computer-executable instructions are used for executing a data updating method.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: when a video object acquisition request sent by a user is received, judging whether a target video object corresponding to target video object information exists in a redis cache, wherein the video object acquisition request at least comprises the target video object information; if the target video object corresponding to the target video object information does not exist in the redis cache, judging whether the target video object corresponding to the target video object information exists in a database or not; if the target video object exists in the database, updating the target video object to the redis cache, and feeding the target video object back to the user; when detecting that the user sends operation updating information based on the target video object, inquiring whether a video object indicated by the operation updating information exists in the database; wherein the video object indicated by the operation update information is the target video object; if the video object indicated by the operation updating information is inquired from the database, updating the video object information of the video object indicated by the operation updating information in the database by using the operation updating information to obtain updated video object information; updating video object information of the target video object in the redis using the updated video object information; if the video object indicated by the operation updating information is not inquired from the database and the optimistic lock is abnormal, emptying the target video object in the redis cache and outputting a target optimistic lock abnormal request, wherein the target optimistic lock abnormal request is the optimistic lock abnormal request aiming at the target video object.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
It should be noted that the computer readable medium mentioned above in the present disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, the system or system embodiments are substantially similar to the method embodiments and therefore are described in a relatively simple manner, and reference may be made to some of the descriptions of the method embodiments for related points. The above-described system and system embodiments are merely illustrative, wherein units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. 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 invention. Thus, the present invention 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.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that it is obvious to those skilled in the art that various modifications and improvements can be made without departing from the principle of the present invention, and these modifications and improvements should also be considered as the protection scope of the present invention.

Claims (10)

1. A method for updating data, the method comprising:
when a video object acquisition request sent by a user is received, judging whether a target video object corresponding to target video object information exists in a redis cache, wherein the video object acquisition request at least comprises the target video object information;
if the target video object corresponding to the target video object information does not exist in the redis cache, judging whether the target video object corresponding to the target video object information exists in a database or not;
if the target video object exists in the database, updating the target video object to the redis cache, and feeding the target video object back to the user;
when detecting that the user sends operation updating information based on the target video object, inquiring whether a video object indicated by the operation updating information exists in the database; wherein the video object indicated by the operation update information is the target video object;
if the video object indicated by the operation updating information is inquired from the database, updating the video object information of the video object indicated by the operation updating information in the database by using the operation updating information to obtain updated video object information;
updating video object information of the target video object in the redis using the updated video object information;
if the video object indicated by the operation updating information is not inquired from the database and the optimistic lock is abnormal, emptying the target video object in the redis cache and outputting a target optimistic lock abnormal request, wherein the target optimistic lock abnormal request is the optimistic lock abnormal request aiming at the target video object.
2. The method of claim 1, further comprising:
detecting whether the output frequency of the target optimistic lock abnormal request is greater than a preset output threshold value in real time;
if the frequency of outputting the target optimistic lock abnormal request is larger than the preset output threshold value, outputting corresponding alarm information;
and if the frequency of outputting the target optimistic lock abnormal request is not greater than the preset output threshold value, the current video object information of the target video object in the database is used as the target video object information of the target video object request again, and the operation is returned to judge whether the target video object corresponding to the target video object information exists in the redis cache.
3. The method of claim 1, wherein the video object information includes a target id, and the determining whether the target video object exists in the database if the target video object does not exist in the redis cache comprises:
and if the target video object corresponding to the target id does not exist in the redis cache, judging whether the target video object corresponding to the target id exists in a database or not.
4. The method according to claim 1, wherein if the video object indicated by the operation update information is queried from the database, updating the video object information of the video object indicated by the operation update information in the database by using the operation update information to obtain updated video object information, and including:
if the video object indicated by the operation updating information is inquired from the database, updating the video object information of the video object indicated by the operation updating information in the database by using the operation updating information based on preset atomic operation to obtain updated video object information;
wherein updating the video object information of the video object indicated by the operation update information in the database by using the operation update information at least comprises updating the version number of the video object indicated by the operation update information in the database by using the operation update information.
5. The method of claim 1, further comprising:
and if the target video object exists in the redis cache, acquiring the target video object from the redis cache, and feeding the target video object back to the user.
6. The method of claim 1, further comprising:
and if the target video object does not exist in the database, feeding back an empty video object to the user.
7. An apparatus for updating data, the apparatus comprising:
the device comprises a first judging unit, a second judging unit and a third judging unit, wherein the first judging unit is used for judging whether a target video object corresponding to target video object information exists in a redis cache when a video object acquisition request sent by a user is received, and the video object acquisition request at least comprises the target video object information;
a second determining unit, configured to determine whether a target video object corresponding to the target video object information exists in a database if the target video object corresponding to the target video object information does not exist in the redis cache;
a feedback unit, configured to update the target video object to the redis cache and feed the target video object back to the user if the target video object exists in the database;
the query unit is used for querying whether the database has a video object indicated by the operation updating information when the operation updating information sent by the user based on the target video object is detected; wherein the video object indicated by the operation update information is the target video object;
a first updating unit, configured to update video object information of the target video object in the database to obtain updated video object information if a video object indicated by the operation update information is queried from the database;
a second updating unit, configured to update video object information of the target video object in the redis with the video object information;
and the exception request output unit is used for clearing the target video object in the redis cache and outputting a target optimistic lock exception request if the video object indicated by the operation updating information is not inquired from the database and the optimistic lock is abnormal, wherein the target optimistic lock exception request is an optimistic lock exception request aiming at the target video object.
8. The apparatus of claim 7, further comprising:
the real-time detection unit is used for detecting whether the output frequency of the target optimistic lock abnormal request is greater than a preset output threshold value or not in real time;
the alarm information output unit is used for outputting corresponding alarm information if the frequency of outputting the target optimistic lock abnormal request is greater than the preset output threshold;
and the re-determining unit is used for re-using the current video object request of the target video object in the database as the target video object request if the frequency of outputting the target optimistic lock abnormal request is not greater than the preset output threshold value, and returning to execute the first judging unit.
9. An electronic device, comprising a processor and a memory, the memory for storing data and program code for data update, the processor for invoking program instructions in the memory to perform a data update method according to any one of claims 1-6.
10. A storage medium, characterized in that the storage medium comprises a stored program, wherein a device on which the storage medium is located is controlled to perform a data updating method according to any one of claims 1-6 when the program runs.
CN202111536561.XA 2021-12-16 2021-12-16 Data updating method and device, electronic equipment and storage medium Active CN113961743B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111536561.XA CN113961743B (en) 2021-12-16 2021-12-16 Data updating method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111536561.XA CN113961743B (en) 2021-12-16 2021-12-16 Data updating method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113961743A CN113961743A (en) 2022-01-21
CN113961743B true CN113961743B (en) 2022-03-01

Family

ID=79473270

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111536561.XA Active CN113961743B (en) 2021-12-16 2021-12-16 Data updating method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113961743B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114282048B (en) * 2022-03-07 2022-05-27 飞狐信息技术(天津)有限公司 Playing record warehousing method and device, storage medium and electronic equipment
CN116361016B (en) * 2023-06-01 2023-10-13 天翼云科技有限公司 Message processing method and system of network controller

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105354247A (en) * 2015-10-13 2016-02-24 武汉大学 Geographical video data organization management method supporting storage and calculation linkage
CN109284894A (en) * 2018-08-10 2019-01-29 广州虎牙信息科技有限公司 Picture examination method, apparatus, storage medium and computer equipment
CN110008376A (en) * 2019-03-22 2019-07-12 广州新视展投资咨询有限公司 User's portrait vector generation method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105354247A (en) * 2015-10-13 2016-02-24 武汉大学 Geographical video data organization management method supporting storage and calculation linkage
CN109284894A (en) * 2018-08-10 2019-01-29 广州虎牙信息科技有限公司 Picture examination method, apparatus, storage medium and computer equipment
CN110008376A (en) * 2019-03-22 2019-07-12 广州新视展投资咨询有限公司 User's portrait vector generation method and device

Also Published As

Publication number Publication date
CN113961743A (en) 2022-01-21

Similar Documents

Publication Publication Date Title
CN113961743B (en) Data updating method and device, electronic equipment and storage medium
KR101960007B1 (en) Opportunistic network updates
CN111291103B (en) Interface data analysis method and device, electronic equipment and storage medium
CN110365745B (en) Data processing system, method, apparatus, server and computer readable medium
CN109408481B (en) Log collection rule updating method and device, electronic equipment and readable medium
CN110139118B (en) Function running method and device of application program, electronic equipment and storage medium
CN112579695A (en) Data synchronization method and device
US8639720B2 (en) Data access method and configuration management database system
CN110990038B (en) Method, apparatus, electronic device and medium for applying local update
CN111310145B (en) User right verification method and device and electronic equipment
CN112711515A (en) Real-time monitoring method and device and electronic equipment
CN110545313B (en) Message push control method and device and electronic equipment
CN113360348B (en) Abnormal request processing method and device, electronic equipment and storage medium
CN111274104A (en) Data processing method and device, electronic equipment and computer readable storage medium
CN110888847B (en) Recycle bin system and file recycling method
CN110727694B (en) Data processing method, device, electronic equipment and storage medium
US10924491B2 (en) Process manager for digital communication
CN112416980A (en) Data service processing method, device and equipment
CN113014456A (en) Monitoring data transmission system, method, device, equipment and storage medium
CN112507676A (en) Energy report generation method and device, electronic equipment and computer readable medium
CN113138943A (en) Method and device for processing request
CN113742355A (en) Method, device, equipment and computer readable medium for updating inventory
CN113722193A (en) Method and device for detecting page abnormity
CN115348260B (en) Information processing method, device, equipment and medium based on campus information security
CN110262756B (en) Method and device for caching data

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
GR01 Patent grant
GR01 Patent grant