Resource sharing and data query method, device and server

By using Redis's shared data table and reference counting in resource sharing between users, the write diffusion and read diffusion problems are solved, resource management and querying are simplified, and service performance and database efficiency are improved.

CN115914387BActive Publication Date: 2024-09-13BIGO TECH PTE LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211363501.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-02
Publication Date
2024-09-13
Estimated Expiration
2042-11-02

AI Technical Summary

Technical Problem

In the existing technology, there are write diffusion and read diffusion problems when sharing resources between users, resulting in data redundancy, slow query, excessive database load, and service lag.

Method used

Use a shared data table based on Redis to record the number of users sharing resources through reference counting, avoid writing shared resources into the resource data table of associated users, simplify resource management and query processes, and reduce database operations.

Benefits of technology

It reduces data redundancy and maintenance costs, improves service performance, reduces database pressure, and improves resource sharing and query efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115914387B
    Figure CN115914387B
Patent Text Reader

Abstract

The present application discloses a method, device and server for resource sharing and data query, wherein the resource sharing method comprises: when it is detected that the sharing level of a user meets the standard, obtaining a first sharable resource list of the user; determining a list of associated users of the user; obtaining a shared data table of each associated user in the associated user list, wherein the shared data table is a data table based on a Redis storage structure, the shared data table carries a user identifier, and the shared data table includes a shared resource identifier and a corresponding reference count, wherein the reference count is used to record the number of users who share the shared resource corresponding to the shared resource identifier with the user identifier; updating the shared data table of each associated user according to each sharable resource in the first sharable resource list, avoiding the problem of write diffusion, making the management of shared resources as concise and efficient as possible, reducing the maintenance cost of shared resources between users, and thus improving service performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a resource sharing method, a data query method, a resource sharing device, a data query device, a server, a computer-readable storage medium, and a computer program product. Background Art

[0002] With the development of Internet technology, there is a demand for sharing user resources between users. When certain conditions are met between users, they can use each other's special virtual assets. For example, in the game scenario, when the user's VIP level reaches a certain level, some of his game props can be shared with other teammates in the same game. For another example, in the live broadcast scenario, when the friendship level reaches a certain level, some of his props (avatar frames, skin cards, room entry special effects, etc.) can be shared with friends, and some props owned by friends can also be used.

[0003] In related technologies, the method of sharing user resources between users is as follows:

[0004] Method 1: When a user obtains a resource that can be shared, the user first writes the resource into the user's own item table, and then checks whether the user has a qualified sharing friend. If so, the item information of the resource is also written into the item table of the sharing friend. In this way, when the user queries the information of the items available to him, he only needs to query the item table under his name. However, this method has a write diffusion problem, that is, if the user has multiple qualified sharing friends, the user needs to write the information of the resource into the item table of each sharing friend when obtaining the shareable resource, so that the information of the resource needs to be written into multiple copies (depending on the number of sharing friends). Although this can simplify the process when the user queries the list of available items, it also greatly causes data redundancy, resulting in problems such as an increase in the amount of data in the user's item table and slow query. It also directly leads to problems such as the trouble of recycling shared resources. For example, when a shared item is shared with a user by multiple different sharing friends, for example, B, C, and D all have the same item and share it with A, even if A and B terminate the sharing relationship, A can still share and use the item from C and D. Therefore, the shared item information under A's name cannot be cleared at this time, so it is necessary to record the shared items from which users the item can be shared. This makes the data storage and sharing privilege recovery process very complicated.

[0005] Method 2: When a user obtains a resource that can be shared, only his own item table is written. Then when the user queries the information of his available items, he first checks the item table under his name, then checks whether there are any qualified sharing friends, and if so, checks the sharable items under the names of the sharing friends. The difference between this method and method 1 is that this method does not write the shared resources to the item table of the sharing friends, making the process of updating shared items very simple and eliminating the resource recycling process. However, this method has the problem of read diffusion, that is, when the user queries his available item list, in addition to checking the items under his name, he also needs to check whether there are any qualified sharing friends. If so, he continues to check whether there are any sharable resources under the names of each sharing friend. Therefore, any user needs to check the database at least 3 times (when there are no qualified sharing friends) and at most 4 times (when there are qualified sharing friends) every time he queries the available item list. The frequency of users querying their own item list is generally much higher than the update frequency of their own item table. Therefore, if the number of users is large and the user item information is frequently pulled, this solution may cause problems such as excessive database load and service lag. Summary of the invention

[0006] The present application provides a method, device and server for resource sharing and data query, so as to solve the problems of write diffusion, read diffusion and frequent database operations existing in the prior art when resources are shared among users.

[0007] According to a first aspect of the present application, a resource sharing method is provided, the method comprising:

[0008] When it is detected that the sharing level of the user meets the requirement, obtaining a first sharable resource list of the user;

[0009] Determine a list of associated users of the user;

[0010] Obtain a shared data table for each associated user in the associated user list, wherein the shared data table is a data table based on a Redis storage structure, carries a user identifier, and includes a shared resource identifier and a corresponding reference count, wherein the reference count is used to record the number of users who share the shared resource corresponding to the shared resource identifier with the user identifier;

[0011] The shared data table of each associated user is updated according to each sharable resource in the first sharable resource list.

[0012] According to a second aspect of the present application, a method for data query is provided, the method comprising:

[0013] In response to a resource query request from a user, reading resource data in a resource data table of the user as first resource data;

[0014] Read resource data in the shared data table of the user as the second resource data, wherein the shared data table is a data table based on the Redis storage structure, the shared data table carries a user identifier, and the shared data table includes a shared resource identifier and a corresponding reference count, and the reference count is used to record the number of users who share the shared resource corresponding to the shared resource identifier with the user identifier;

[0015] A resource display list is generated based on the first resource data and the second resource data, and the resource display list is returned.

[0016] According to a third aspect of the present application, a resource sharing device is provided, the device comprising:

[0017] A first sharable resource list acquisition module, configured to acquire a first sharable resource list of the user when it is detected that the sharing level of the user meets the requirement;

[0018] An associated user list determination module, used to determine the associated user list of the user;

[0019] A first shared data table acquisition module is used to acquire a shared data table of each associated user in the associated user list, wherein the shared data table is a data table based on a Redis storage structure, and carries a user identifier. The shared data table includes a shared resource identifier and a corresponding reference count, and the reference count is used to record the number of users who share the shared resource corresponding to the shared resource identifier with the user identifier;

[0020] The first shared data table updating module is configured to update the shared data table of each associated user according to each sharable resource in the first sharable resource list.

[0021] According to a fourth aspect of the present application, a data query device is provided, the device comprising:

[0022] A first query module, configured to respond to a resource query request of a user and read resource data in a resource data table of the user as first resource data;

[0023] A second query module is used to read resource data in the shared data table of the user as the second resource data, wherein the shared data table is a data table based on the Redis storage structure, the shared data table carries a user identifier, and the shared data table includes a shared resource identifier and a corresponding reference count, and the reference count is used to record the number of users who share the shared resource corresponding to the shared resource identifier with the user identifier;

[0024] The resource display list generating module is used to generate a resource display list based on the first resource data and the second resource data, and return the resource display list.

[0025] According to a fifth aspect of the present application, a server is provided, the server comprising:

[0026] at least one processor; and

[0027] a memory communicatively connected to the at least one processor; wherein,

[0028] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the method described in the first aspect or the second aspect.

[0029] According to a sixth aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method described in the first aspect or the second aspect when executed.

[0030] According to a seventh aspect of the present application, a computer program product is provided, the computer program product comprising computer executable instructions, the computer executable instructions being used to implement the method described in the first aspect or the second aspect when executed.

[0031] In this embodiment, the shared resources obtained by each user are maintained through a shared data table, and the reference count of each shared resource is recorded in the shared data table. The number of users who can provide the current shared resource to the user is recorded through the reference count. When resource sharing is required, the management of shared resources is directly realized through the reference count, without writing the shared resources into the resource data table of each associated user, and no additional data is added to the resource data table of each associated user, which reduces data redundancy and coupling between tables and avoids the problem of write diffusion. Subsequent operations such as query, update, and recycling based on shared resources are all realized based on the reference count, making the management of shared resources as simple and efficient as possible, reducing the maintenance cost of shared resources between users, and thus improving service performance.

[0032] Furthermore, the shared data table of this embodiment is a data table based on the Redis storage structure. Compared with the read and write operations on the database, Redis has higher read and write efficiency, which reduces the number of database read and write operations. In high concurrency scenarios, it can greatly improve service performance and reduce the pressure on the database.

[0033] When performing resource queries, only one database query (query in the resource data table) and one Redis query (query in the shared data table) are required. There is no need to query the resource data table of each associated user separately. The number of IO operations is reduced, the read diffusion problem is avoided, and the number of database operations is effectively reduced, thereby reducing the database load and improving service response efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0035] Figure 1 This is a flow chart of a resource sharing method provided in Example 1 of the present application;

[0036] Figure 2 is a schematic diagram of a storage structure of a shared data table provided in Example 1 of the present application;

[0037] Figure 3 This is a flow chart of a resource sharing method provided in Example 2 of the present application;

[0038] Figure 4 This is a flow chart of a resource sharing method provided in Example 3 of the present application;

[0039] Figure 5 This is a flow chart of a resource sharing method provided in Example 4 of the present application;

[0040] Figure 6 This is a flow chart of a resource sharing method provided in Example 5 of the present application;

[0041] Figure 7 This is a flow chart of a resource sharing method provided in Example 6 of the present application;

[0042] Figure 8 This is a flow chart of a resource sharing method provided in Embodiment 7 of the present application;

[0043] Fig. 9 is a schematic diagram of a resource display list provided in Embodiment 7 of the present application;

[0044] Fig.10 This is a schematic diagram of the structure of a resource sharing device provided in Embodiment 8 of the present application;

[0045] Fig.11 It is a structural schematic diagram of a data query device provided in Embodiment 9 of the present application;

[0046] Fig.12 This is a structural diagram of a server provided in Example 10 of the present application. DETAILED DESCRIPTION

[0047] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0048] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0049] Embodiment 1

[0050] Figure 1 A flow chart of a resource sharing method provided in Embodiment 1 of the present application is applied to a scenario in which resources are shared between users. This embodiment can be executed by a server, such as Figure 1 As shown, this embodiment may include the following steps:

[0051] Step 101: when it is detected that the sharing level of a user reaches a certain level, a first sharable resource list of the user is obtained.

[0052] The user may be any user registered in the server.

[0053] Different types of sharing levels can be set according to different application scenarios. For example, a sharing level can be set for an individual user, and the user can increase the sharing level by performing specified operations; or, a relationship sharing level can be set for the association between two users, and the sharing level can be updated based on the interaction between the two users.

[0054] The above-mentioned achievement of the standard may be achievement of a preset condition, and the preset condition may vary according to different application scenarios.

[0055] The server monitors the sharing level of each user. If it is detected that a user's sharing level meets the standard, the server obtains the user's shareable resource list, where the shareable resource list includes one or more shareable resources. The shareable resources are different from the general resources that all users have. They refer to specific resources that can only be enjoyed after reaching a certain level. Exemplarily, the resource can be a virtual resource. For example, in a live broadcast scenario, the resource can include live broadcast prop resources such as skins, room entry effects, and avatar frames; in a game scenario, the resource can include game prop resources such as skins, game effects, and heroes. General resources can be, for example, free resources, while shareable resources can be VIP resources.

[0056] During implementation, in the sharable resource list, each sharable resource may be represented by a resource identifier (eg, resource ID, item ID).

[0057] For the sake of distinction, in this embodiment, the sharable resource list of the user who currently meets the sharing level requirement is referred to as the first sharable resource list, and the sharable resource list of other users different from the current user may be referred to as the second sharable resource list hereinafter.

[0058] In one implementation, when it is necessary to obtain the first sharable resource list, all resources of the current user may be obtained first, and then sharable resources may be selected from all resources to form the first sharable resource list. Specifically, a corresponding resource information table may be configured for each resource in the server, and the resource information table may be cached in the memory, as shown in Table 1 below. The resource information table may include fields such as resource ID, resource type, resource name, resource icon, and whether it is sharable. In addition, the resource information table may also specify a primary key:

[0059]

[0060]

[0061] Table 1

[0062] Whether the resource is a shareable resource can be determined based on the value of the is_shareable field of each resource. If is_shareable=1, it means that the resource is a shareable resource, and if is_shareable=0, it means that the resource is a non-shareable resource.

[0063] Step 102: Determine a list of associated users of the current user.

[0064] Among them, the associated user list may include at least one associated user. In one embodiment, the associated user may be other users who have an interactive relationship with the current user and meet the set conditions. For example, in a game scenario, the associated user may be a teammate of the current user. In a live broadcast scenario, the associated user may be a user who follows the current user or a user followed by the current user. In an instant messaging scenario, the associated user may be a friend user of the current user.

[0065] In one implementation, all users associated with the current user may be first obtained, and then users meeting set conditions may be selected from all the users as associated users.

[0066] In other embodiments, the associated user may also be another user specified by the user, for example, the associated user is a user selected by the current user in his or her friend list, or a user searched by the current user.

[0067] On the other hand, if the current user has no associated users that meet the set conditions, the process ends.

[0068] Step 103: Obtain a shared data table of each associated user in the associated user list.

[0069] The shared data table (ShareTable) is a data table based on the Redis storage structure. The RedisHash structure can be used to store data in the shared data table. RedisHash is an open source key-value storage database written in ANSI C language, compliant with the BSD (Berkeley Software Distribution) protocol, supporting the network, memory-based, distributed, and optionally persistent, and provides APIs in multiple languages. Hash is a key-value mapping data type supported by Redis, suitable for storing object-type data.

[0070] In this embodiment, each shared data table carries the user ID of the corresponding associated user, and the shared data table may include a shared resource ID and a corresponding reference count, wherein the reference count is used to record the number of users who share the shared resource corresponding to the shared resource ID with the user ID.

[0071] For example, the storage structure of a shared data table can be as follows Figure 2 As shown, in Figure 2In , the key format of the shared data table is: PREFIX_${uid}, where PREFIX is a fixed prefix and ${uid} is the unique uid of the user corresponding to the shared data table. For each shared data table, its field is the resource ID of the shared resource obtained by the uid, and the value is the reference count, which indicates how many users can provide the corresponding shared resource for the current uid. For example, in Figure 2 In the example, the reference count of item_id1 is 3, which means that the number of users who can provide item_id1 for the current uid is 3, that is, there are 3 users who share the resource item_id1 for the current uid.

[0072] Step 104: update the shared data table of each associated user according to each sharable resource in the first sharable resource list.

[0073] In the maintenance and management of the shared data table, if a user's sharing level meets the standard, the associated shared data table can be updated according to the sharable resource list of the user who meets the standard, so that each associated user can share the sharable resources of the current user.

[0074] In one implementation, the resource identifier of each sharable resource in the first sharable resource list can be obtained, and each resource identifier can be matched in the shared data table of each associated user; for each shared data table, if a resource identifier is successfully matched in the shared data table, the reference count corresponding to the matched shared resource identifier in the shared data table is increased by 1; if a resource identifier fails to match in the shared data table, the source identifier is added to the shared data table as a shared resource identifier, and its reference count is marked as 1.

[0075] For example, the sharable resources included in the first sharable resource list are item_id1, item_id2, and item_id8. Figure 2 When the shared data table is updated, item_id1 and item_id2 can match, but item_id8 does not match. In this case, the reference count 3 of item_id1 can be incremented by 1 to get a reference count of 4, and the reference count 1 of item_id2 can be incremented by 1 to get a reference count of 2. Item_id8 is added to the shared data table with a reference count of 1.

[0076] In this embodiment, the shared resources obtained by each user are maintained through a shared data table, and the reference count of each shared resource is recorded in the shared data table. The number of users who can provide the current shared resource to the user is recorded through the reference count. When resource sharing is required, the management of shared resources is directly realized through the reference count, without writing the shared resources into the resource data table of each associated user, and no additional data is added to the resource data table of each associated user, which reduces data redundancy and coupling between tables and avoids the problem of write diffusion. Subsequent operations such as query, update, and recycling based on shared resources are all realized based on the reference count, making the management of shared resources as simple and efficient as possible, reducing the maintenance cost of shared resources between users, and thus improving service performance.

[0077] Furthermore, the shared data table of this embodiment is a data table based on the Redis storage structure. Compared with the read and write operations on the database, Redis has higher read and write efficiency, which reduces the number of database read and write operations. In high concurrency scenarios, it can greatly improve service performance and reduce the pressure on the database.

[0078] Embodiment 2

[0079] Figure 3 This is a flow chart of a resource sharing method provided in Embodiment 2 of the present application. Based on Embodiment 1, this embodiment describes a scenario of detecting whether the sharing level meets the standard and determining the associated user. Figure 3 As shown, this embodiment may include the following steps:

[0080] Step 201: When the relationship level between a user and one or more of the relationship users in the relationship list reaches a set relationship level threshold, it is determined that the sharing level of the user meets the requirement.

[0081] Exemplarily, the relationship list may include a friend relationship list, and the relationship users are friend users who follow each other with the current user.

[0082] In implementation, a relationship table may be maintained for each relationship in the server, as shown in Table 2. The relationship table may include fields such as relationship id, relationship initiator uid, relationship recipient uid, relationship level, relationship creation time, etc.:

[0083]

[0084] Table 2

[0085] Step 202: determine the related users whose relationship level reaches the set relationship level threshold as associated users, and generate an associated user list.

[0086] For example, assuming that user A and user B are friends, when the friendship level between the two is upgraded to level 5 (assuming level 5 is the set friendship level), it can be determined that the sharing level between user A and user B has reached the standard. If user A is the current user at this time, user B is the associated user of user A. If user B is the current user at this time, user A is the associated user of user B.

[0087] For another example, assuming that the friendship levels of user A with users B, C, and D are all upgraded to level 5, and user A is the current user, then users B, C, and D are all associated users of user A, and the associated user list includes users B, C, and D.

[0088] Step 203: Obtain a shared data table of each associated user in the associated user list.

[0089] Among them, the shared data table is a data table based on the Redis storage structure, the shared data table carries a user identifier, and the shared data table may include a shared resource identifier and a corresponding reference count, and the reference count is used to record the number of users who share the shared resource corresponding to the current shared resource identifier with the user identifier.

[0090] Step 204: update the shared data table of each associated user according to each sharable resource in the first sharable resource list.

[0091] This embodiment illustrates an implementation scenario of sharing resources between users with an associated relationship. When the relationship level between two users reaches a set relationship level threshold, the other party's shared data table can be updated according to the sharable resource list of the two users, thereby realizing sharing and management of shared resources between the two users, simplifying the difficulty of managing shared resources between users and improving service performance.

[0092] Embodiment 3

[0093] Figure 4 This is a flow chart of a resource sharing method provided in Embodiment 3 of the present application. Based on Embodiment 1, this embodiment describes another scenario of detecting whether the sharing level meets the standard and determining the associated user. Figure 4 As shown, this embodiment may include the following steps:

[0094] Step 301: When the sharing level of a user reaches a set level threshold, it is determined that the sharing level of the user meets the standard.

[0095] Step 302: taking users who have a specified association relationship with the user as associated users, and generating an associated user list.

[0096] Step 303: Obtain a shared data table of each associated user in the associated user list.

[0097] Among them, the shared data table is a data table based on the Redis storage structure, the shared data table carries a user identifier, and the shared data table includes a shared resource identifier and a corresponding reference count, and the reference count is used to record the number of users who share the shared resource corresponding to the shared resource identifier with the user identifier.

[0098] Step 304: Update the shared data table of each associated user according to each sharable resource in the first sharable resource list.

[0099] The difference between this embodiment and the second embodiment is that this embodiment does not need to judge the relationship level between the two users. Instead, when the sharing level of a single user reaches the set level threshold, the sharing level of the user is determined to be up to standard, and then the user who has a specified association relationship with the current user is directly used as an associated user. Among them, the specified association relationship can be set differently according to different application scenarios. For example, in a game scenario, the specified association relationship can be a teammate relationship. That is to say, in a game team, if the game level of a game user reaches the set level threshold, the sharable resources of the game user can be shared with other teammates. The sharing and management of shared resources between users with specified association relationships is realized, which simplifies the management difficulty of shared resources and improves service performance.

[0100] Embodiment 4

[0101] Figure 5 A flowchart of a resource sharing method provided in Embodiment 4 of the present application. This embodiment, based on any one of Embodiments 1 to 3, describes a process of mutual resource sharing between users. Figure 5 As shown, this embodiment may include the following steps:

[0102] Step 401: when it is detected that the sharing level of a user reaches a certain level, a first sharable resource list of the user is obtained.

[0103] Step 402: Determine a list of associated users of the user.

[0104] Step 403: Obtain a shared data table of each associated user in the associated user list.

[0105] Among them, the shared data table is a data table based on the Redis storage structure. The shared data table carries a user identifier. The shared data table includes a shared resource identifier and a corresponding reference count. The reference count is used to record the number of users who share the shared resource corresponding to the current shared resource identifier with the user identifier.

[0106] Step 404: update the shared data table of each associated user according to each sharable resource in the first sharable resource list.

[0107] Step 405: Obtain a second sharable resource list of each associated user.

[0108] Step 406, obtaining the shared data table of the current user.

[0109] Step 407: update the shared data table of the current user according to the second sharable resource lists of the associated users.

[0110] In this embodiment, in addition to updating the shared data table of associated users according to the first sharable resource list of the current user, the shared data table of the current user can also be updated according to the second sharable resource list of each associated user. For example, assuming that the friendship level of user A with users B and C is upgraded to level 5, user A is the current user, and users B and C are both associated users of user A. The relationship between each resource ID and the corresponding reference count in the current shared data table of user A is shown in Table 3 below:

[0111]

[0112]

[0113] Table 3

[0114] Assuming that the second sharable resource list of user B is {item_id1, item_id7}, the shared data table of user A shown in Table 1 is updated according to the second sharable resource list of user B, the reference count of item_id1 is incremented by 1, and the reference count of item_id7 is incremented by 1, and the result is

[0115] Table 4 shared data table:

[0116] Resource ID Reference counting item_id1 4 item_id2 1 item_id4 2 item_id7 2

[0117] Table 4

[0118] Assuming that the second sharable resource list of user C is {item_id2, item_id3}, the shared data table of user A shown in Table 2 is updated according to the second sharable resource list of user C, the reference count of item_id2 is incremented by 1, and a record of item_id3 is added and its reference count is set to 1, so as to obtain the shared data table of Table 5:

[0119] Resource ID Reference counting item_id1 4 item_id2 2 item_id3 1 item_id4 2 item_id7 2

[0120] Table 5

[0121] It should be noted that when there is more than one associated user, when the second sharable resource list of each associated user is used to update the shared data table of the current user, in order to avoid errors in writing data, a thread lock may be used to lock the shared data table of the current user.

[0122] In this embodiment, resource management of mutual resource sharing between two users is implemented through a shared data table, which simplifies the management process of mutual resource sharing and improves the management efficiency of resource sharing.

[0123] Embodiment 5

[0124] Figure 6 This is a flow chart of a resource sharing method provided in Embodiment 5 of the present application. This embodiment describes the process of adding a new shared resource based on any one of Embodiments 1 to 4. Figure 6 As shown, this embodiment may include the following steps:

[0125] Step 501: when it is detected that the sharing level of a user reaches a certain level, a first sharable resource list of the user is obtained.

[0126] Step 502: Determine a list of associated users of the user.

[0127] Step 503: Obtain a shared data table of each associated user in the associated user list.

[0128] Among them, the shared data table is a data table based on the Redis storage structure. The shared data table carries a user identifier. The shared data table may include a shared resource identifier and a corresponding reference count. The reference count is used to record the number of users who share the shared resource corresponding to the current shared resource identifier with the user identifier.

[0129] Step 504: update the shared data table of each associated user according to each sharable resource in the first sharable resource list.

[0130] Step 505: When the current user obtains a new shared resource, the new shared resource is written into the resource data table of the current user.

[0131] The resource data table is a data table used to record the user's own resources. Each user's own resources can be recorded in the resource data table in the form of resource identifiers.

[0132] The resource data table can be stored in a database, such as a MySQL database.

[0133] Step 506: Update the shared data table of each associated user according to the new shared resource.

[0134] Among them, the method for updating the shared data table of each associated user can refer to the description of step 104 in Example 1, that is, traverse the shared data table of each associated user, if the new shared resource exists in the shared data table of the associated user, then the reference count corresponding to the resource identifier of the new shared resource is incremented by 1; if the new shared resource does not exist in the shared data table of the associated user, then the resource identifier of the new shared resource is added to the shared data table and the corresponding reference count is set to 1.

[0135] In this embodiment, when a user adds a new shared resource, the shared data table of each associated user is directly updated according to the newly added shared resource through Redis operation, without writing the newly added shared resource into the resource data table of each associated user, thus avoiding the write diffusion problem, simplifying the processing flow of new shared resources, and improving the maintenance efficiency of shared resources, thereby better improving service performance.

[0136] Embodiment 6

[0137] Figure 7 This is a flow chart of a resource sharing method provided in Example 6 of the present application. This embodiment describes the recycling process of shared resources based on any one of Examples 1 to 5. Figure 7 As shown, this embodiment may include the following steps:

[0138] Step 601: when it is detected that the sharing level of a user reaches the standard, a first sharable resource list of the user is obtained.

[0139] Step 602: Determine a list of associated users of the user.

[0140] Step 603: Obtain a shared data table of each associated user in the associated user list.

[0141] Among them, the shared data table is a data table based on the Redis storage structure. The shared data table carries a user identifier. The shared data table may include a shared resource identifier and a corresponding reference count. The reference count is used to record the number of users who share the shared resource corresponding to the current shared resource identifier with the user identifier.

[0142] Step 604: update the shared data table of each associated user according to each sharable resource in the first sharable resource list.

[0143] Step 605: When an invalid resource appears in the sharable resources of the current user, a search is performed in the shared data table of each associated user based on the resource identifier of the invalid resource, and the reference count found is reduced by 1.

[0144] Among them, an invalid resource refers to a resource that cannot be shared. If the resource has been shared, it is necessary to recycle the resource. When recycling resources, this embodiment directly updates the reference count in the shared data table. Specifically, the resource identifier of the invalid resource can be found in the shared data table of each associated user, and the reference count in the found data record is reduced by 1.

[0145] For example, in Figure 2 In the example, if the invalid resource is item_id1, the reference count in the data record where item_id1 is located can be updated from 3 to 2.

[0146] In one embodiment, the following method may be used to detect failed resources: when the sharing level of the current user is reduced to a set level threshold, each sharable resource of the user is regarded as a failed resource.

[0147] For example, if the user's sharing level is required to be 7 when the game level is met, if the user's game level drops to 6, which is lower than the required level 7, it means that the user does not have the authority to share resources. At this time, all the user's sharable resources can be treated as invalid resources, and the shared data table of each associated user can be updated one by one using each invalid resource.

[0148] In another embodiment, the following method may be used to detect invalid resources: when the relationship level between a user and one or more associated users is lower than a set relationship level threshold, each sharable resource of the user is regarded as an invalid resource.

[0149] For example, if the friendship level is set to 5, and the friendship level between user A and user B is reduced to 4, the friendship between the two does not meet the standard. Therefore, all sharable resources of user A can be treated as invalid resources, and the shared data table of user B can be updated one by one using each invalid resource. Similarly, all sharable resources of user B can be treated as invalid resources, and the shared data table of user A can be updated one by one using each invalid resource.

[0150] In yet another embodiment, the following method may be used to detect invalid resources: when there are expired sharable resources in the user's first sharable resource list, the expired sharable resources are treated as invalid resources.

[0151] Among them, each sharable resource has a usage period, and if the usage period is exceeded, the corresponding shared resource expires. Specifically, for each sharable resource, the server can also maintain a sharable resource information table, as shown in Table 6 below. The sharable resource information table may include fields such as the user ID (uid) that owns the sharable resource, the resource ID, the resource validity period start time, the resource validity period end time, and the resource acquisition time. If the resource validity period end time of the sharable resource of the current user (uid is the uid of the current user) arrives, it means that the sharable resource has expired:

[0152]

[0153] Table 6

[0154] In this embodiment, expired sharable resources may be used as invalid resources, and the shared data tables of each associated user may be updated using the invalid resources.

[0155] Step 606: When a reference count with a value of 0 appears in the shared data table, the corresponding resource record is deleted from the shared data table.

[0156] After the reference count is decremented, if a reference count with a value of 0 appears in a shared data table, the resource record containing the reference count with a value of 0 is deleted from the shared data table.

[0157] In this embodiment, when recycling shared resources, it is only necessary to operate the reference count in the shared data table without operating the database, which greatly simplifies the resource recycling process and improves the management efficiency of shared resources.

[0158] Embodiment 7

[0159] Figure 8 A flowchart of a resource sharing method provided in Embodiment 7 of the present application. Compared with Embodiments 1 to 6 above, this embodiment focuses on the scenario of reading data, while Embodiments 1 to 6 above focus on the scenario of writing data. Figure 8 As shown, this embodiment may include the following steps:

[0160] Step 701: In response to a resource query request from a user, resource data in a resource data table of the user is read as first resource data.

[0161] When a user needs to query his / her available resources, he / she may initiate a resource query request on the client page. The resource query request carries the user ID of the user.

[0162] After obtaining the user ID of the current user, the resource data table corresponding to the user ID can be found in the database according to the user ID, and the resource data in the resource data table can be read as the first resource data. The resource data table is a data table for recording the resources owned by the user, and the resources owned by each user can be recorded in the resource data table in the form of resource IDs. The first resource data can include the resource IDs of the resources owned by the current user.

[0163] Step 702: Read resource data in the shared data table of the user as second resource data.

[0164] Among them, the shared data table is a data table based on the Redis storage structure, the shared data table carries a user identifier, and the shared data table includes a shared resource identifier and a corresponding reference count, and the reference count is used to record the number of users who share the shared resource corresponding to the shared resource identifier with the user identifier.

[0165] After obtaining the user ID of the current user, the corresponding shared data table can be searched in Redis according to the user ID, and the resource data in the shared data table can be read as the second resource data. The second resource data can include the resource IDs of the resources shared by the current user and the reference counts corresponding to the resource IDs.

[0166] Step 703: Generate a resource display list based on the first resource data and the second resource data, and return the resource display list.

[0167] In implementation, the resource display list is generated by fusing the first resource data and the second resource data. One implementation scheme of the fusion is: writing the first resource data and the second resource data into a pre-configured display template to generate the resource display list.

[0168] The resource display list may include each resource identifier in the first resource data and each resource identifier in the second resource data and the corresponding reference count. If the resource identifier is a code type, it can be converted into a resource name before displaying, such as Fig. 9 As shown, in Fig. 9 In the example, the owned resources come from the first resource data, and the shared resources come from the second resource data.

[0169] In this embodiment, when performing a resource query, only one database query (query in the resource data table) and one Redis query (query in the shared data table) are required. There is no need to query the resource data table of each associated user separately. The number of IO operations is reduced, the read diffusion problem is avoided, and the number of database operations is effectively reduced, thereby reducing the database load and improving service response efficiency.

[0170] At the same time, since the Redis operation performance is several orders of magnitude higher than the database operation, this embodiment can greatly improve the service performance and reduce the database pressure in high concurrency scenarios.

[0171] Embodiment 8

[0172] Fig.10 A schematic diagram of a resource sharing device provided in Embodiment 8 of the present application may include the following modules:

[0173] A first sharable resource list acquisition module 801 is used to acquire a first sharable resource list of the user when it is detected that the sharing level of the user meets the requirement;

[0174] An associated user list determination module 802 is used to determine an associated user list of the user;

[0175] A first shared data table acquisition module 803 is used to acquire a shared data table of each associated user in the associated user list, wherein the shared data table is a data table based on a Redis storage structure, and carries a user identifier. The shared data table includes a shared resource identifier and a corresponding reference count, and the reference count is used to record the number of users who share the shared resource corresponding to the shared resource identifier with the user identifier;

[0176] The first shared data table updating module 804 is configured to update the shared data table of each associated user according to each sharable resource in the first sharable resource list.

[0177] In one embodiment, the shared data table updating module 804 is specifically used for:

[0178] Get the resource identifier of each sharable resource;

[0179] Matching the resource identifier in each of the shared data tables;

[0180] If the match is successful, the reference count corresponding to the matched shared resource identifier is increased by 1;

[0181] If the match fails, the resource identifier is added to the shared data table as a shared resource identifier, and its reference count is marked as 1.

[0182] In one embodiment, the device further includes a first target-reaching detection module, configured to:

[0183] When the relationship level between the user and one or more related users in the relationship list reaches a set relationship level threshold, it is determined that the sharing level of the user meets the requirement.

[0184] In one embodiment, the associated user list determination module 802 is specifically configured to:

[0185] The related users whose relationship levels reach the set relationship level threshold are determined as associated users.

[0186] In another embodiment, the device further includes a second target-reaching detection module, configured to:

[0187] When the sharing level of a user reaches a set level threshold, it is determined that the sharing level of the user meets the requirement.

[0188] In another embodiment, the associated user list determination module 802 is specifically configured to:

[0189] A user who has a specified association relationship with the user is regarded as an associated user.

[0190] In one embodiment, the device may further include:

[0191] A second sharable resource list acquisition module, used to acquire a second sharable resource list of each associated user;

[0192] A second shared data table acquisition module, used to acquire the shared data table of the user;

[0193] The second shared data table updating module is used to update the shared data table of each associated user according to the second sharable resource list of each associated user.

[0194] In one embodiment, the device may further include:

[0195] A resource data table writing module, used for writing the new shared resource into the resource data table of the user when the user obtains the new shared resource;

[0196] A new resource writing module is used to update the shared data table of each associated user according to the new shared resource.

[0197] In one embodiment, the device may further include:

[0198] The resource recovery module is used to search in the shared data table of each associated user based on the resource identifier of the failed resource when an invalid resource appears in the sharable resources of the user, and reduce the reference count found by 1; when the reference count with a value of 0 appears in the shared data table, the corresponding resource record is deleted in the shared data table.

[0199] In one embodiment, the failed resource is detected in the following manner:

[0200] When the sharing level of the user is reduced to a set level threshold, each sharable resource of the user is regarded as an invalid resource;

[0201] or,

[0202] When the first sharable resource list of the user contains expired sharable resources, the expired sharable resources are treated as invalid resources;

[0203] or,

[0204] When the relationship level between the user and one or more associated users is lower than a set relationship level threshold, each sharable resource of the user is regarded as an invalid resource.

[0205] A resource sharing device provided in an embodiment of the present application can execute a resource sharing method provided in any one of embodiments 1 to 6 of the present application, and has functional modules and beneficial effects corresponding to the execution method.

[0206] Embodiment 9

[0207] Fig.11 A schematic diagram of a data query device provided in Embodiment 9 of the present application may include the following modules:

[0208] The first query module 901 is used to respond to a resource query request of a user and read resource data in the resource data table of the user as first resource data;

[0209] The second query module 902 is used to read the resource data in the shared data table of the user as the second resource data, wherein the shared data table is a data table based on the Redis storage structure, the shared data table carries the user identifier, and the shared data table includes a shared resource identifier and a corresponding reference count, and the reference count is used to record the number of users who share the shared resource corresponding to the shared resource identifier with the user identifier;

[0210] The resource display list generating module 903 is used to generate a resource display list based on the first resource data and the second resource data, and return the resource display list.

[0211] A data query device provided in an embodiment of the present application can execute a data query method provided in Embodiment 7 of the present application, and has functional modules and beneficial effects corresponding to the execution method.

[0212] Embodiment 10

[0213] Fig.12 The schematic diagram of the structure of the server 10 that can be used to implement the method embodiment of the present application is shown. Fig.12As shown, the server 10 includes at least one processor 11, and a storage device connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the storage device stores one or more computer programs that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In RAM 13, various programs and data required for the operation of the server 10 can also be stored.

[0214] In some embodiments, the method in any one of Embodiments 1 to 7 may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the server 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the method in any one of Embodiments 1 to 7 described above may be performed.

[0215] In some embodiments, the method in any one of embodiments one to seven may be implemented as a computer program product, which includes computer executable instructions, which, when executed, are used to perform one or more steps of the method in any one of embodiments one to seven described above.

Claims

1. A resource sharing method, characterized in that: The method comprises: When it is detected that the sharing level of the user meets the requirement, obtaining a first sharable resource list of the user; Determine a list of associated users of the user; Obtain a shared data table for each associated user in the associated user list, wherein the shared data table is a data table based on a Redis storage structure, and the shared data table carries a user identifier of the corresponding associated user. The shared data table includes a shared resource identifier and a corresponding reference count, and the reference count is used to record the number of users who share the shared resource corresponding to the shared resource identifier with the user identifier; updating the shared data table of each associated user according to each sharable resource in the first sharable resource list; The updating of the shared data table of each associated user according to each sharable resource in the first sharable resource list includes: Get the resource identifier of each sharable resource; Matching the resource identifier in each of the shared data tables; If the match is successful, the reference count corresponding to the matched shared resource identifier is increased by 1; If the match fails, the resource identifier is added to the shared data table as a shared resource identifier, and its reference count is marked as 1.

2. The method according to claim 1, characterized in that Use the following method to check whether the user's sharing level meets the requirements: When the relationship level between the user and one or more related users in the relationship list reaches a set relationship level threshold, it is determined that the sharing level of the user meets the requirement.

3. The method according to claim 2, characterized in that The determining the associated user list of the user includes: The related users whose relationship levels reach the set relationship level threshold are determined as associated users.

4. The method according to claim 1, characterized in that: After updating the shared data table of each associated user according to each sharable resource in the sharable resource list, the method further includes: Obtain a second sharable resource list of each associated user; Obtaining the shared data table of the user; The shared data table of the user is updated respectively according to the second sharable resource list of each associated user.

5. The method according to claim 1 or 4, characterized in that: The method further comprises: When the user obtains a new shared resource, the new shared resource is written into the resource data table of the user; The shared data table of each associated user is updated according to the new shared resource.

6. The method according to claim 1 or 4, characterized in that: The method further comprises: When an invalid resource appears in the sharable resources of the user, a search is performed in the shared data table of each associated user based on the resource identifier of the invalid resource, and the reference count found is reduced by 1; When the reference count with a value of 0 appears in the shared data table, the corresponding resource record is deleted in the shared data table.

7. The method according to claim 6, characterized in that The failed resource is detected in the following manner: When the sharing level of the user is reduced to a set level threshold, each sharable resource of the user is regarded as an invalid resource; or, When the first sharable resource list of the user contains expired sharable resources, the expired sharable resources are treated as invalid resources; or, When the relationship level between the user and one or more associated users is lower than a set relationship level threshold, each sharable resource of the user is regarded as an invalid resource.

8. A method for data query, characterized in that: The method comprises: In response to a resource query request from a user, reading resource data in a resource data table of the user as first resource data; Read resource data in the shared data table of the user as the second resource data, wherein the shared data table is a data table based on the Redis storage structure, the shared data table carries the user identifier of the user to which it belongs, and the shared data table includes a shared resource identifier and a corresponding reference count, and the reference count is used to record the number of users who share the shared resource corresponding to the shared resource identifier with the user identifier; A resource display list is generated based on the first resource data and the second resource data, and the resource display list is returned.

9. A resource sharing device, characterized in that: The device comprises: A first sharable resource list acquisition module, configured to acquire a first sharable resource list of the user when it is detected that the sharing level of the user meets the requirement; An associated user list determination module, used to determine the associated user list of the user; A first shared data table acquisition module is used to acquire a shared data table of each associated user in the associated user list, wherein the shared data table is a data table based on a Redis storage structure, and the shared data table carries a user identifier of the corresponding associated user. The shared data table includes a shared resource identifier and a corresponding reference count, and the reference count is used to record the number of users who share the shared resource corresponding to the shared resource identifier with the user identifier; A first shared data table updating module, configured to update the shared data table of each associated user according to each sharable resource in the first sharable resource list; The first shared data table updating module is specifically used for: Get the resource identifier of each sharable resource; Matching the resource identifier in each of the shared data tables; If the match is successful, the reference count corresponding to the matched shared resource identifier is increased by 1; If the match fails, the resource identifier is added to the shared data table as a shared resource identifier, and its reference count is marked as 1.

10. A data query device, characterized in that: The device comprises: A first query module, configured to respond to a resource query request of a user and read resource data in a resource data table of the user as first resource data; A second query module is used to read resource data in the shared data table of the user as the second resource data, wherein the shared data table is a data table based on the Redis storage structure, the shared data table carries the user identifier of the user to which it belongs, and the shared data table includes a shared resource identifier and a corresponding reference count, and the reference count is used to record the number of users who share the shared resource corresponding to the shared resource identifier with the user identifier; The resource display list generating module is used to generate a resource display list based on the first resource data and the second resource data, and return the resource display list.

11. A server, characterized in that: The server comprises: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 8.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.

13. A computer program product, comprising computer executable instructions, wherein the computer executable instructions are used to implement the method according to any one of claims 1 to 8 when executed.