Resource object information processing method and device, electronic equipment and storage medium
By using asynchronous write queues and proactively updating caches in hot resource type resource objects, the problem of low processing efficiency of high concurrent comment instructions and view instructions is solved, and system stability and user experience are improved.
Patent Information
- Application Number
- CN202510059551.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-14
- Publication Date
- 2025-05-13
AI Technical Summary
When facing resource objects of hot resource types, the prior art is difficult to quickly, accurately and efficiently process highly concurrent comment instructions and viewing instructions, resulting in large database write load and frequent cache failure, which in turn causes database instability.
When determining that the resource object is a hot resource type, the asynchronous write queue of the database is used for peak-cutting processing, and the first resource information in the cache is actively updated, thereby avoiding frequent cache failure and excessive database instantaneous pressure.
It realizes fast, accurate and efficient processing of comment instructions and viewing instructions for hot resource type resource objects, improves system stability and user experience, and avoids database exceptions.
Smart Images

Figure CN119988754A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to big data and database management in computer technology, and in particular to a method, device, electronic device and storage medium for information processing of resource objects. Background Art
[0002] With the rapid development of the Internet, various hot resources such as hot news, hot videos, and hot topics are widely disseminated on the Internet, attracting a large number of users' attention and comments. When faced with high concurrency of comment instructions and view instructions for hot resources, how to quickly, accurately and efficiently process comment instructions and view instructions to ensure user experience and database stability has become an urgent problem to be solved. Summary of the invention
[0003] The present disclosure provides a method, apparatus, device and storage medium for information processing of resource objects.
[0004] According to a first aspect of the present disclosure, there is provided a method for processing information of a resource object, comprising:
[0005] In response to a comment instruction of a user for a resource object, writing the comment content indicated by the comment instruction into a database; wherein the comment instruction represents the comment content posted by the user on the resource object;
[0006] When it is determined that the resource object is a hotspot resource type, updating the first resource information corresponding to the resource object in the database to the cache, and deleting the second resource information corresponding to the resource object from the cache;
[0007] Among them, the first resource information is resource information that, when querying the resource information of a resource object, the time consumed by retrieving the database is greater than or equal to a first preset time length; the second resource information is resource information that, when querying the resource information of a resource object, the time consumed by retrieving the database is less than the first preset time length; the resource information of the resource object is determined according to the comment content of the resource object.
[0008] According to a second aspect of the present disclosure, there is provided a resource object information processing device, comprising:
[0009] A database writing unit, configured to respond to a comment instruction of a user for a resource object and write the comment content indicated by the comment instruction into a database; wherein the comment instruction represents the comment content posted by the user on the resource object;
[0010] A cache processing unit, configured to update the first resource information corresponding to the resource object in the database to the cache and delete the second resource information corresponding to the resource object from the cache when determining that the resource object is a hot resource type;
[0011] Among them, the first resource information is resource information that, when querying the resource information of a resource object, the time consumed by retrieving the database is greater than or equal to a first preset time length; the second resource information is resource information that, when querying the resource information of a resource object, the time consumed by retrieving the database is less than the first preset time length; the resource information of the resource object is determined according to the comment content of the resource object.
[0012] According to a third aspect of the present disclosure, there is provided an electronic device, including:
[0013] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method described in the first aspect.
[0014] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute the method described in the first aspect.
[0015] According to a fifth aspect of the present disclosure, a computer program product is provided, comprising: a computer program, wherein the computer program is stored in a readable storage medium, at least one processor of an electronic device can read the computer program from the readable storage medium, and the at least one processor executes the computer program so that the electronic device executes the method described in the first aspect.
[0016] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0018] Figure 1 is a schematic diagram according to a first embodiment of the present disclosure;
[0019] Figure 2 is a schematic diagram according to a second embodiment of the present disclosure;
[0020] Figure 3 is a schematic diagram according to a third embodiment of the present disclosure;
[0021] Figure 4 is a schematic diagram according to a fourth embodiment of the present disclosure;
[0022] Figure 5 is a schematic diagram according to a fifth embodiment of the present disclosure;
[0023] Figure 6 is a schematic diagram according to a sixth embodiment of the present disclosure;
[0024] Figure 7 is a schematic diagram according to a seventh embodiment of the present disclosure;
[0025] Figure 8 Schematic block diagram of an example electronic device that can be used to implement embodiments of the present disclosure. DETAILED DESCRIPTION
[0026] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0027] With the rapid development of the Internet, various resource objects such as news, videos, and topics are widely spread on the Internet, attracting a large number of users' attention and comments. When a user posts a comment or queries a comment, the client submits the comment instruction or query instruction to the backend server of the server through an HTTP request for processing. The client can obtain the return result of the backend server of the server and render the page according to the return result. Among them, the comment instruction can include the comment content posted by the user on a resource object.
[0028] Among them, after receiving the comment instruction submitted by the user, the backend Server of the server can write the comment content contained in the comment instruction into the database. Optionally, the server can also perform risk control review on the comment content. When the server needs to perform risk control review on the comment content, the database is in the submitted state when writing to the database. In the submitted state, the user cannot view the comment content. After the review is passed, the server can modify the comment content in the database to a displayable state. In the displayable state, the user can request to view the comment content.
[0029] At present, in order to ensure the data consistency between the server cache and the database, the resource information corresponding to the resource object in the cache can be deleted after it is determined that the newly added comment content that can be displayed appears. The resource information is specifically information related to the resource object corresponding to the comment content. For example, the resource information may include the comment content of the resource object, the number of comments on the resource object, etc.
[0030] At the same time, the server can also push the comment ID of the comment request into the comment sorting library to perform an overall sorting of the comment area content.
[0031] When a user accesses the resource object, the user can request to view the resource information of the resource object. The resource information includes comments on the resource object, the number of comments on the resource object, etc. The comment content of the resource object can be displayed sequentially according to the arrangement order in the comment sorting library. Specifically, in response to the user's viewing request, the server can obtain the resource information that needs to be viewed. The server can first query the resource information in the cache. If the cache does not hit the resource information, it will call the database to query the resource information. After obtaining the resource information from the database, the server can write the resource information into the cache and return it to the user. Optionally, when the query request contains multiple resource information, the server can write all the resource information required by the query request into the cache, and then return the multiple resource information together to the client.
[0032] However, when some of the news, videos or topics are highly discussed, the type of resource object of the news, video or topic will become a hot resource type. Compared with non-hot resource types, hot resource types usually have large traffic and will have high concurrency of comment instructions and viewing instructions. The high concurrency of comment instructions and viewing instructions will further lead to a large write load on the database, and will involve frequent cache invalidation operations, resulting in a decrease in cache hit rate, which in turn leads to an increase in the read load of the database, thereby causing database instability and a decrease in database availability.
[0033] Therefore, how to quickly, accurately and efficiently process comment instructions and view instructions for resource objects of hot resource types has become an urgent problem to be solved.
[0034] Based on the above technical problems, the present disclosure provides an information processing method for resource objects of hot resource types with large traffic. This method can solve the problem in the prior art that when facing resource objects of hot resource types, large traffic comments are written, resulting in low comment update efficiency and poor system stability. Specifically, after determining that the resource object belongs to the hot resource type, the method can perform peak shaving processing on the write operation of the resource object through the asynchronous write queue of the database. The use of the asynchronous write queue can avoid instantaneous pressure in the database writing process by controlling the consumption speed of the asynchronous write queue. And, the method can actively update the cache for the first resource information, thereby avoiding the problem of frequent cache failures leading to a decrease in cache hit rate. Through the asynchronous write queue and the active update of the cache, the control of the database read and write frequency can be achieved, thereby avoiding database anomalies caused by excessive instantaneous pressure on the database, thereby improving system stability.
[0035] The present invention discloses a resource object information processing method, device, electronic device and storage medium, which are applied to big data and database management in computer technology to achieve fast, accurate and efficient processing of comment instructions and view instructions to ensure user experience and database stability.
[0036] It should be noted that the head model in this embodiment is not a head model for a specific user and cannot reflect the personal information of a specific user. It should be noted that the two-dimensional face image in this embodiment comes from a public data set.
[0037] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0038] In order to enable readers to more deeply understand the implementation principle of the present disclosure, the following Figure 2-Figure 5 right Figure 1 The illustrated embodiment is further refined.
[0039] Figure 1 is a schematic diagram according to the first embodiment of the present disclosure, such as Figure 1 As shown, the present disclosure provides a method for processing information of a resource object, the method comprising:
[0040] 101. In response to a comment instruction from a user on a resource object, write the comment content indicated by the comment instruction into a database, wherein the comment instruction represents the comment content posted by the user on the resource object.
[0041] In this embodiment, after receiving a comment instruction from a user for a resource object, the resource object commented on by the user and the comment content posted by the user are obtained by parsing the comment instruction. Optionally, the resource object may include a resource ID. A resource ID may uniquely correspond to a resource object. Optionally, the comment content may correspond to a comment ID. A comment ID may uniquely correspond to a comment content. Optionally, key information such as user information and timestamp may also be obtained from the comment instruction. Subsequently, the comment content is written into the database by establishing a secure connection with the database. Optionally, the database write operation may be implemented by constructing an SQL insert statement to insert the comment content into the data table corresponding to the database.
[0042] Optionally, after obtaining the comment instruction, the user identity and user authority can be verified based on the user information extracted from the comment instruction, thereby ensuring the legitimacy of the user and the user's authority to comment on the resource object. Optionally, after obtaining the comment instruction, the validity can be verified based on the resource object extracted from the comment instruction, thereby ensuring that the resource object is a valid object.
[0043] 102. When it is determined that the resource object is a hotspot resource type, first resource information corresponding to the resource object in the database is updated to the cache, and second resource information corresponding to the resource object is deleted from the cache.
[0044] The first resource information is resource information for which the time consumed by calling the database when querying the resource information of the resource object is greater than or equal to the first preset time length. The second resource information is resource information for which the time consumed by calling the database when querying the resource information of the resource object is less than the first preset time length. The resource information of the resource object is determined according to the comment content of the resource object.
[0045] In this embodiment, first, the resource type of the resource object can be determined based on the resource object of the comment instruction parsed in step 101. The resource type may include two types: hotspot resource type and non-hotspot resource type. For all resource types of a resource object, in this embodiment, they are divided into two categories: first resource information and second resource information, wherein the first resource information refers to resource information whose time consumed during query is greater than or equal to the first preset duration, and the second resource information refers to resource information whose query time is less than the preset duration. After determining that the resource object belongs to the hotspot resource type, the first resource information of the resource object can be requested from the database, and the first resource information can be updated to the cache to speed up subsequent access. At the same time, the second resource information of the resource object in the cache can be deleted to optimize the efficiency of cache use.
[0046] In this embodiment, after receiving a comment instruction from a user for a resource object, the resource object commented on by the user and the comment content posted by the user are obtained by parsing the comment instruction. The comment content is written into the database by establishing a secure connection with the database. After determining that the resource object belongs to a hot resource type, the first resource information of the resource object can be requested from the database, and the first resource information can be updated to the cache to speed up subsequent access. At the same time, the second resource information of the resource object in the cache can be deleted to optimize the efficiency of cache use. Through the above steps, when the comment content is written to the database according to the comment instruction, the cache is dynamically updated, the access efficiency of the resource objects of the hot resource type and the stability of the database when the comment content is written are improved, and the overall user experience is improved.
[0047] Based on the above embodiment, when it is determined that the resource object is a non-hotspot resource type, the first resource information and the second resource information corresponding to the resource object may be deleted from the cache.
[0048] In this embodiment, the resource type of the resource object can be determined based on the resource object of the comment instruction parsed in step 101. When it is determined that the resource object is a non-hotspot resource type, the resource information of the resource object in the cache can be synchronously deleted when the comment content of the resource object is written into the database, thereby avoiding the situation where the resource information in the cache is inconsistent with the database. Optionally, when the resource object is a non-hotspot resource type, the resource information deleted in the cache may include the first resource information and the second resource information in the above step 102.
[0049] Figure 2 is a schematic diagram according to the second embodiment of the present disclosure, such as Figure 2 As shown, in a resource object information processing method provided by the present disclosure, the specific process of updating the first resource information corresponding to the resource object in the database to the cache may include:
[0050] 201. Request the database for the read permission of the resource object, and add an update lock of the resource object in the database, wherein the update lock indicates that other processes cannot read the resource information of the resource object from the database.
[0051] In this embodiment, when it is determined that the first resource information needs to be obtained from the database, the read permission of the resource object can be requested from the database first. If no process in the database is reading the resource information of the resource object at this time, the read permission of the database to read the resource object can be obtained. At this time, an update lock can be added to the resource object in the database. After the update lock is added to the resource object in the database, other processes will not be able to read the resource object in the database.
[0052] The update lock will be released after the acquisition of the first resource information is completed. When the update lock is released, other processes can read the resource information of the resource object from the database. The setting of the update lock can limit the read and write frequency of the resource object, ensuring that only one data is reading the resource information of the resource object at the same time, thereby reducing the access frequency of the database and improving the stability of the database.
[0053] Furthermore, since the resource information that takes a long time to query in this application can be read in the cache, the restriction on the reading frequency of the resource object by the update lock will not have a significant impact on user access.
[0054] Optionally, the number of update locks of a resource object can also be limited in the database. That is, when the number of update locks of the resource object is less than a preset threshold, if a new process accesses the resource object, the database can allow the process to access the resource object and add an update lock. When the number of update locks of the resource object reaches the preset threshold, if a new process accesses the resource object, the database will not allow the process to access the resource object. The setting of the preset threshold can be determined according to the throughput of the database. And, the preset value can also be dynamically adjusted according to the number of resource objects of the hot resource type. The method can achieve control of database stability and improve database stability by dynamically adjusting the number of processes accessing a resource object.
[0055] 202. Request first resource information of a resource object from a database.
[0056] In this embodiment, after the update lock of the resource object is set in the database, the database may be requested to obtain the first resource information of the resource object. Optionally, when multiple first resource information are included, the multiple first resource information may be sequentially obtained from the database.
[0057] In one example, requesting first resource information of a resource object from a database includes:
[0058] 2021. If it is determined that the first resource information exists in the database, read the first resource information of the resource object from the database.
[0059] In this embodiment, it is first determined whether the first resource information can exist directly in the database. When the first resource information exists directly in the database, the first resource information can be obtained by querying from the database through a simple query instruction. For example, when the first resource information is a comment content, the first resource information can be directly obtained from the database. A database query instruction can be generated based on the comment ID indicated in the first resource information, and the first resource information can be queried through the database query instruction.
[0060] 2022. If it is determined that the first resource information does not exist in the database, generate the first resource information of the resource object according to the comment content of the resource object in the database.
[0061] In this embodiment, when the first resource information does not exist directly in the database, it is necessary to query the first resource information from the database through the query instruction preset by the first resource information. For example, when the first resource information is the number of comments, the first resource information can also be directly obtained from the database. Based on the resource ID indicated in the first resource information, a database quantity query instruction can be generated. And through the quantity query instruction, the number of comments corresponding to the resource object can be queried.
[0062] 203. Use the requested first resource information to overwrite the original first resource information in the cache.
[0063] In this embodiment, after the first resource information of the resource object is obtained, the first resource information can be used to overwrite the original first resource information in the cache to ensure that the data in the cache is the latest.
[0064] 204. If, when requesting the database for the read permission of the resource object, it is determined that the database already has the update lock of the resource object, the cache is not updated.
[0065] In this embodiment, when requesting the database for the read permission of the resource object in step 201, if the update lock has been set for the resource object in the database, it means that there is already a process reading the resource information of the resource object. At this time, the cache update operation generated by writing the comment content can be directly abandoned. The strategy can further reduce the update frequency of the database and reduce the risk of abnormality in the database.
[0066] In this embodiment, when it is determined that the first resource information needs to be obtained from the database, the read permission of the resource object can be requested from the database first. If the read permission of the resource object of the database is obtained, an update lock can be added to the resource object in the database. After the update lock of the resource object is set in the database, a request can be made to the database to obtain the first resource information of the resource object. And the first resource information is used to overwrite the original first resource information in the cache. If the update lock of the resource object in the database has been set, the cache update operation generated based on the write of the comment content can be directly abandoned. By setting the update lock, obtaining the first resource information, and actively updating the first resource information in the cache, the frequency of database access can be further reduced, thereby improving the stability of the database.
[0067] Figure 3 is a schematic diagram according to the third embodiment of the present disclosure, Figure 3 As shown, in a resource object information processing method provided by the present disclosure, the specific process of determining that a resource object is a hot resource type includes:
[0068] 301. Obtain the resource type of the resource object corresponding to the comment instruction. If the resource type indicates a hot resource type, determine that the resource object is a hot resource type. The hot resource type indicates that the number of first comments on the resource object within a first preset time period is greater than or equal to a preset number.
[0069] In this embodiment, each resource object may be provided with a resource type attribute. After obtaining the resource object in the comment instruction, it is possible to determine whether the resource object is a hot resource type by querying the resource type of the resource object. If the resource type of the resource object indicates a hot resource type, the resource object is determined to be a hot resource type. Otherwise, if the resource type of the resource object indicates a non-hot resource type, the resource object is determined to be a non-hot resource type.
[0070] Specifically, the number of first comments on the resource object of the hot resource type within a first preset time period is greater than or equal to a preset number.
[0071] Optionally, the number of first comments for each resource object within a first preset duration can be calculated in real time. And the number of first comments is compared with the preset number. If the number of first comments is greater than or equal to the preset number, and the resource type of the resource object is a non-hotspot resource type, the resource type of the resource object can be directly modified to a hotspot resource type. Optionally, the first preset duration can be 1 minute, 2 minutes, 5 minutes, etc. The preset number can be 80, 120, 200, etc.
[0072] 302. If the number of comments on the resource object within the first preset time period is less than a preset number, determine whether the asynchronous write queue of the database contains comment content of the resource object within the preset time window.
[0073] In this embodiment, after calculating in real time the first number of comments for each resource object within the first preset time period and comparing the first number of comments with the preset number, if it is determined that the first number of comments is less than the preset number and the resource type of the resource object is a hot resource type, it is necessary to further determine whether the resource type needs to be modified to a non-hot resource type.
[0074] Specifically, when it is determined that the first number of comments is less than a preset number and the resource type of the resource object is a hot resource type, it can be determined at the queue head of the asynchronous write queue of the database whether the comment content of the resource object is included within the preset time window.
[0075] Optionally, the asynchronous write queue includes the comment content indicated by the comment instruction of the hot resource. Each comment content corresponds to a resource object. The comment content in the asynchronous write queue is added to the asynchronous write queue from the end of the queue according to the time sequence. And, the asynchronous write queue dequeues the comment content from the head of the queue according to the preset consumption speed. The consumed comment content is written into the database.
[0076] Optionally, the preset time window can be set according to the writing time of the comment content. That is, the deadline is determined according to the timestamp of the comment content at the head of the queue and the time length indicated by the time window. All the comment content from the head of the queue to the deadline is obtained from the asynchronous write queue. It is determined whether the comment content contains the comment content of the resource object.
[0077] Optionally, the preset time window can also be set according to the dequeue time of the comment content. That is, according to the preset dequeue speed and the time length indicated by the preset time window, the number of comments contained in the window can be calculated. According to the number, the multiple comment contents are obtained from the asynchronous write queue starting from the head of the queue. It is determined whether the comment content contains the comment content of the resource object.
[0078] 303. If the comment content of the resource object is not included in the preset time window, the resource object is determined to be a non-hotspot resource type.
[0079] In this embodiment, if the comment content of the resource object is not included in the preset time window, it is determined that the number of comments on the resource object has decreased and it is no longer a hot spot. At this time, the resource type of the resource object can be set to a non-hot resource. Otherwise, if the comment content of the resource object is included in the preset time window, you can continue to wait.
[0080] Optionally, in one implementation, the subsequent operation may be performed directly after waiting for the next comparison result between the first number of comments within the first preset time and the preset number. Optionally, the period of the comparison between the first number of comments within the first preset time and the preset number may be determined according to the preset time. For example, when the first preset time is 2 minutes, the period may be 30 seconds, 1 minute, 2 minutes, 4 minutes, etc.
[0081] Optionally, in another implementation, it is possible to periodically determine whether the asynchronous write queue contains the comment content of the resource object within a preset time window. The period can be determined according to the preset time window. For example, when the preset time window is 30 seconds, the period can be 10 seconds, 15 seconds, 30 seconds, 1 minute, 1 minute and 30 seconds, etc.
[0082] In this embodiment, the number of first comments for each resource object within the first preset time length can be calculated in real time. And the first number of comments is compared with the preset number. If the first number of comments is greater than or equal to the preset number, and the resource type of the resource object is a non-hotspot resource type, the resource type of the resource object can be directly modified to a hotspot resource type. If it is determined that the first number of comments is less than the preset number, and the resource type of the resource object is a hotspot resource type, it can be determined at the queue head of the asynchronous write queue of the database whether the comment content of the resource object is included in the preset time window. If the comment content of the resource object is not included in the preset time window, the resource type of the resource object can be set to a non-hotspot resource. By counting the number of comments on the resource object, the resource type of the resource object is judged, thereby assisting in optimizing the overall resource management and system performance.
[0083] Figure 4 is a schematic diagram according to a fourth embodiment of the present disclosure, Figure 4 As shown, the present disclosure provides a method for processing information of a resource object, the method comprising:
[0084] 401. In response to a user's query instruction, query the cache for target resource information indicated by the query instruction.
[0085] In this embodiment, when a user issues a query instruction, the target resource information indicated by the query instruction can be identified after the instruction is obtained and parsed. First, the target resource information can be searched in the cache. When the cache contains the target resource information, the target resource information can be quickly found.
[0086] 402. If the cache does not contain the target resource information, or the cache contains only part of the target resource information, then the database is retrieved and the target resource information that is not contained in the cache is queried from the database.
[0087] In this embodiment, since the target resource information can be one or more, when part or all of the target resource information is not found in the cache, the target resource information can be further queried in the database. This query can ensure that the user can obtain complete target resource information. After the target resource information is queried from the database, the target resource information can be written into the cache. The cache can return all the target resource information indicated by the user query request to the user together.
[0088] 403. If the time consumed for querying the target resource information from the database is greater than or equal to the first preset time length, the target resource information is recorded as the first resource information.
[0089] In this embodiment, in the process of querying the target resource information from the database, the time consumed for querying the target resource information can also be obtained. If the time is greater than or equal to the first preset duration, it can be determined that the target resource information consumes more resources in the query of the database, and the target resource information can be recorded as the first resource information and directly updated in the cache later.
[0090] 404. If the number of queries for the first resource information within the second preset time period is less than the preset number, the first resource information is recorded as the second resource information.
[0091] In this embodiment, the number of queries for the first resource information within the second preset time period can also be counted according to the query instruction of the user. If the number of queries is small, it means that there are not many users who need to view the information, and writing the first resource information in the cache for a long time will lead to a waste of cache resources. Therefore, when the number of queries is less than the second preset time period, the first resource information can be recorded as the second resource information.
[0092] In this embodiment, when a user issues a query instruction, the target resource information indicated by the query instruction can be identified after the instruction is obtained and parsed. When part or all of the target resource information is not found in the cache, the target resource information can be further queried in the database. The time consumed for querying the target resource information is obtained. If the time is greater than or equal to the first preset time length, the target resource information can be recorded as the first resource information. It is also possible to count the number of queries for the first resource information within the second preset time length based on the user's query instruction. When the number of queries is less than the second preset time length, the first resource information is recorded as the second resource information. Through the above process, the first resource information in the cache is dynamically adjusted to ensure that the user can obtain resource information that has been queried for a long time in the database from the cache, thereby improving the user's query efficiency, reducing the database load, optimizing database performance, and improving user experience.
[0093] Figure 5 is a schematic diagram according to a fifth embodiment of the present disclosure, Figure 5 As shown, the present disclosure provides a method for processing information of a resource object, the method comprising:
[0094] S501: Determine the hotspot resource type.
[0095] In this embodiment, when a user uploads a comment instruction for a resource object, it is first determined whether the resource object belongs to a hot resource type. Specifically, the determination of the hot resource type can use Redis to add a comment count, thereby obtaining the first number of comments on the resource object within a first preset time. If the first number of comments is greater than or equal to the preset number, the resource object is determined to be a hot resource type. For example, if the number of comments exceeds 120 within 2 minutes.
[0096] S502: Comment overload processing.
[0097] In this embodiment, when a resource object is determined to be a hot resource type, the state of the resource object can be sent through a distributed file system. When the resource object is determined to be a hot resource type, when adding a comment, the comment content can be put into an asynchronous write queue, and the data block can be asynchronously written through the asynchronous write queue, thereby realizing peak shaving processing.
[0098] 503. Cache penetration processing.
[0099] In this embodiment, when the resource object is a hot resource object, the cache processing method of the resource object is different from the cache processing method of the non-hot resource type. Among them, for the cache of non-hot resource types, when the comment content of the resource object is updated in the database, all caches of the resource object can be deleted. For hot resource types, when the comment content of the resource object is updated in the database, the first resource information can be obtained from the database and updated to the cache, and the second resource information can be deleted from the cache.
[0100] Optionally, in order to further limit the amount of access to the database, the access frequency may be set for the database, for example, only one process is allowed to access the resource object in the database at a time.
[0101] S504: Hotspot resource exits.
[0102] In this embodiment, when the number of comments on a resource object of a hot resource type decreases, the asynchronous write queue of the database can be checked first to determine whether it contains unprocessed comments on the resource object. If so, a heartbeat of a preset period can be used for detection until the comments on the resource object in the asynchronous queue are consumed. For example, the preset period can be 10s, 20s, etc. The state of the resource object of the hot resource type is modified to a non-hot resource type and sent down.
[0103] In this embodiment, by determining whether a resource object is a hot resource type or a non-hot resource type, the processing of resource objects of hot resource types in the cache is implemented, thereby improving user query efficiency and improving the stability of the database system when resource objects of hot resource types appear.
[0104] Figure 6 is a schematic diagram according to a sixth embodiment of the present disclosure, Figure 6 As shown, the present disclosure provides a resource object information processing device 600, the device comprising:
[0105] The database writing unit 601 is used to respond to a comment instruction of a user on a resource object and write the comment content indicated by the comment instruction into the database, wherein the comment instruction represents the comment content posted by the user on the resource object.
[0106] The cache processing unit 602 is used to update the first resource information corresponding to the resource object in the database to the cache and delete the second resource information corresponding to the resource object from the cache when determining that the resource object is a hot resource type.
[0107] The first resource information is resource information for which the time consumed by calling the database when querying the resource information of the resource object is greater than or equal to the first preset time length. The second resource information is resource information for which the time consumed by calling the database when querying the resource information of the resource object is less than the first preset time length. The resource information of the resource object is determined according to the comment content of the resource object.
[0108] The device of this embodiment can execute the technical solution in the above method. Its specific implementation process and technical principles are the same and will not be repeated here.
[0109] Figure 7 is a schematic diagram according to the seventh embodiment of the present disclosure, Figure 7 As shown, the present disclosure provides a resource object information processing device 700, the device comprising:
[0110] The database writing unit 701 is used to respond to a comment instruction of a user on a resource object and write the comment content indicated by the comment instruction into the database, wherein the comment instruction represents the comment content posted by the user on the resource object.
[0111] The cache processing unit 702 is used to update the first resource information corresponding to the resource object in the database to the cache and delete the second resource information corresponding to the resource object from the cache when determining that the resource object is a hot resource type.
[0112] The first resource information is resource information for which the time consumed by calling the database when querying the resource information of the resource object is greater than or equal to the first preset time length. The second resource information is resource information for which the time consumed by calling the database when querying the resource information of the resource object is less than the first preset time length. The resource information of the resource object is determined according to the comment content of the resource object.
[0113] Optionally, the cache processing unit 702 includes:
[0114] The acquisition module 7022 is used to request the first resource information of the resource object from the database.
[0115] The writing module 7023 is used to use the requested first resource information to overwrite the original first resource information in the cache.
[0116] Optionally, the acquisition module 7022 includes:
[0117] The first acquisition submodule 70221 is used to read the first resource information of the resource object from the database when it is determined that the first resource information exists in the database.
[0118] The second acquisition submodule 70222 is used to generate the first resource information of the resource object according to the comment content of the resource object in the database when it is determined that the first resource information does not exist in the database.
[0119] Optionally, the cache processing unit 702 further includes:
[0120] The first permission module 7021 is used to request the read permission of the resource object from the database and add an update lock of the resource object in the database, wherein the update lock indicates that other processes cannot read the resource information of the resource object from the database.
[0121] Optionally, the cache processing unit 702 further includes:
[0122] The second permission module 7024 is used for not updating the cache when requesting the database for the read permission of the resource object and determining that the database already has the update lock of the resource object.
[0123] Optionally, the cache processing unit 702 includes:
[0124] The first determination module 7025 is used to obtain the resource type of the resource object corresponding to the comment instruction. If the resource type indicates a hot resource type, the resource object is determined to be a hot resource type. The hot resource type indicates that the number of first comments on the resource object within a first preset time period is greater than or equal to a preset number.
[0125] Optionally, the cache processing unit 702 further includes:
[0126] The second determination module 7026 is used to determine whether the asynchronous write queue of the database contains the comment content of the resource object within the preset time window if the number of comments on the resource object within the first preset time length is less than the preset number. If the comment content of the resource object is not contained within the preset time window, the resource object is determined to be a non-hot resource type.
[0127] Optionally, the cache processing unit 702 is further configured to:
[0128] When it is determined that the resource object is a non-hotspot resource type, the first resource information and the second resource information corresponding to the resource object are deleted from the cache.
[0129] Optionally, the information processing device 700 further includes:
[0130] The cache query unit 703 is used to query the target resource information indicated by the query instruction from the cache in response to the user's query instruction.
[0131] The database query unit 704 is used to call the database and query the database for the target resource information that is not included in the cache if the cache does not include the target resource information or the cache only includes part of the target resource information.
[0132] The resource information classification unit 705 is configured to record the target resource information as first resource information if the time consumed for searching the database for the target resource information is greater than or equal to a first preset time duration.
[0133] Optionally, the resource information classification unit 705 is further configured to:
[0134] If the number of inquiries for the first resource information within the second preset time period is less than the preset number, the first resource information is recorded as the second resource information.
[0135] The device of this embodiment can execute the technical solution in the above method. Its specific implementation process and technical principles are the same and will not be repeated here.
[0136] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0137] According to an embodiment of the present disclosure, the present disclosure also provides a computer program product, which includes: a computer program, the computer program is stored in a readable storage medium, at least one processor of an electronic device can read the computer program from the readable storage medium, and at least one processor executes the computer program so that the electronic device executes the solution provided by any of the above embodiments.
[0138] Figure 8 A schematic block diagram of an example electronic device 800 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0139] like Figure 8As shown, the device 800 includes a computing unit 801, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 802 or a computer program loaded from a storage unit 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the device 800 can also be stored. The computing unit 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0140] A number of components in the device 800 are connected to the I / O interface 805, including: an input unit 806, such as a keyboard, a mouse, etc.; an output unit 807, such as various types of displays, speakers, etc.; a storage unit 808, such as a disk, an optical disk, etc.; and a communication unit 809, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 809 allows the device 800 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0141] The computing unit 801 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 801 performs the various methods and processes described above, such as the information processing method of the resource object. For example, in some embodiments, the information processing method of the resource object may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 808. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 800 via ROM 802 and / or communication unit 809. When the computer program is loaded into RAM 803 and executed by the computing unit 801, one or more steps of the information processing method of the resource object described above may be performed. Alternatively, in other embodiments, the computing unit 801 may be configured to execute the information processing method of the resource object by any other appropriate means (e.g., by means of firmware).
[0142] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0143] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0144] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A 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, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0145] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0146] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0147] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "VPS" for short). The server may also be a server of a distributed system, or a server combined with a blockchain.
[0148] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0149] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A method for processing information of a resource object, comprising: In response to a comment instruction of a user for a resource object, writing the comment content indicated by the comment instruction into a database; wherein the comment instruction represents the comment content posted by the user on the resource object; When it is determined that the resource object is a hotspot resource type, updating the first resource information corresponding to the resource object in the database to the cache, and deleting the second resource information corresponding to the resource object from the cache; Among them, the first resource information is resource information that, when querying the resource information of a resource object, the time consumed by retrieving the database is greater than or equal to a first preset time length; the second resource information is resource information that, when querying the resource information of a resource object, the time consumed by retrieving the database is less than the first preset time length; the resource information of the resource object is determined according to the comment content of the resource object.
2. The method according to claim 1, wherein: The updating of the first resource information corresponding to the resource object in the database to the cache includes: Requesting the database for first resource information of the resource object; The requested first resource information is used to overwrite the original first resource information in the cache.
3. The method according to claim 2, wherein: The requesting the database for the first resource information of the resource object includes: If it is determined that the first resource information exists in the database, reading the first resource information of the resource object from the database; If it is determined that the first resource information does not exist in the database, the first resource information of the resource object is generated according to the comment content of the resource object in the database.
4. The method according to claim 2 or 3, wherein: Before requesting the database for the first resource information of the resource object, the method further includes: Request the database for the read permission of the resource object, and add an update lock of the resource object in the database; wherein the update lock indicates that other processes cannot read the resource information of the resource object from the database.
5. The method according to claim 4, further comprising: If, when requesting the database for the read permission of the resource object, it is determined that the database already has the update lock of the resource object, the cache is not updated.
6. The method according to any one of claims 1 to 5, wherein: The determining that the resource object is a hotspot resource type includes: Obtaining a resource type of a resource object corresponding to the comment instruction; if the resource type indicates a hot resource type, determining that the resource object is a hot resource type; The hot resource type indicates that the number of first comments on the resource object within a first preset time period is greater than or equal to a preset number.
7. The method according to claim 6, further comprising: If the number of comments on the resource object within the first preset time period is less than the preset number, determining whether the asynchronous write queue of the database contains the comment content of the resource object within the preset time window; If the comment content of the resource object is not included in the preset time window, it is determined that the resource object is a non-hotspot resource type.
8. The method according to any one of claims 1 to 7, further comprising: When it is determined that the resource object is a non-hotspot resource type, the first resource information and the second resource information corresponding to the resource object are deleted from the cache.
9. The method according to any one of claims 1 to 8, further comprising: In response to a user's query instruction, querying the cache for target resource information indicated by the query instruction; If the cache does not contain the target resource information, or the cache contains only part of the target resource information, then accessing the database and querying the database for the target resource information that is not contained in the cache; If the time consumed for querying the target resource information from the database is greater than or equal to a first preset time length, the target resource information is recorded as first resource information.
10. The method according to claim 9, further comprising: If the number of inquiries for the first resource information within the second preset time period is less than the preset number, the first resource information is recorded as the second resource information.
11. An information processing device for a resource object, comprising: A database writing unit, configured to respond to a comment instruction of a user for a resource object and write the comment content indicated by the comment instruction into a database; wherein the comment instruction represents the comment content posted by the user on the resource object; A cache processing unit, configured to update the first resource information corresponding to the resource object in the database to the cache and delete the second resource information corresponding to the resource object from the cache when determining that the resource object is a hot resource type; Among them, the first resource information is resource information that, when querying the resource information of a resource object, the time consumed by retrieving the database is greater than or equal to a first preset time length; the second resource information is resource information that, when querying the resource information of a resource object, the time consumed by retrieving the database is less than the first preset time length; the resource information of the resource object is determined according to the comment content of the resource object.
12. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 10.
13. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-10.
14. A computer program product, comprising a computer program, which implements the steps of the method according to any one of claims 1 to 10 when executed by a processor.