WO2024093675A1 - Resource sharing method and apparatus, data query method and apparatus, and server - Google Patents

Resource sharing method and apparatus, data query method and apparatus, and server Download PDF

Info

Publication number
WO2024093675A1
WO2024093675A1 PCT/CN2023/125200 CN2023125200W WO2024093675A1 WO 2024093675 A1 WO2024093675 A1 WO 2024093675A1 CN 2023125200 W CN2023125200 W CN 2023125200W WO 2024093675 A1 WO2024093675 A1 WO 2024093675A1
Authority
WO
WIPO (PCT)
Prior art keywords
resource
user
data table
shared
list
Prior art date
Application number
PCT/CN2023/125200
Other languages
French (fr)
Chinese (zh)
Inventor
梅超
Original Assignee
广州市百果园信息技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 广州市百果园信息技术有限公司 filed Critical 广州市百果园信息技术有限公司
Publication of WO2024093675A1 publication Critical patent/WO2024093675A1/en

Links

Classifications

    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/70Game security or game management aspects
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/131Protocols for games, networked simulations or virtual reality
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/568Storing data temporarily at an intermediate stage, e.g. caching
    • H04L67/5682Policies or rules for updating, deleting or replacing the stored data
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/21Server components or server architectures
    • H04N21/218Source of audio or video content, e.g. local disk arrays
    • H04N21/2187Live feed
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/47End-user applications
    • H04N21/478Supplemental services, e.g. displaying phone caller identification, shopping application
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the present application relates to the field of data processing technology, for example, 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.
  • VIP Very Important Person
  • some of his game props can be shared with other teammates in the same game.
  • some of his props can be shared with friends, and some props owned by friends can also be used.
  • the method of sharing user resources between users is as follows:
  • 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.
  • 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 in multiple copies (depending on the number of sharing friends).
  • Method 2 When a user obtains a resource that can be shared, he only writes his own item table and then uses When a 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 items that can be shared 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.
  • this method has a read diffusion problem, that is, when a 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, and if so, he continues to check whether there are any resources that can be shared 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) each time he queries the available item list.
  • the frequency of users generally querying their own item lists is much higher than the update frequency of their own item tables. Therefore, if the number of users is large and the user item information is frequently pulled under this solution, it may cause problems such as excessive database load and service jams.
  • 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 related art when resources are shared among users.
  • the present application provides a resource sharing method, the method comprising:
  • 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 reference count corresponding to the shared resource identifier, 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;
  • At least one shared data table of the associated user is updated according to at least one sharable resource in the first sharable resource list.
  • the present application also provides a method for querying data, the method comprising:
  • resource data in a resource data table of the user is read, and the resource data in the resource data table read is used as first resource data;
  • the shared data table is a data table based on the Redis storage structure
  • the shared data table carries the user identifier
  • the shared data table includes the shared resource identifier and the reference count corresponding to the shared resource identifier
  • the reference count is used to record the shared resource identifier of the user. the number of users sharing the resource corresponding to the shared resource 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.
  • the embodiment of the present application also provides a resource sharing device, the device comprising:
  • a first sharable resource list acquisition module configured to acquire a first sharable resource list of the user when detecting that the sharing level of the user meets the requirement
  • An associated user list determination module configured to determine an associated user list of the user
  • a first shared data table acquisition module is configured to acquire a shared data table of at least one 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 reference count corresponding to the shared resource identifier, 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;
  • the first shared data table updating module is configured to update the shared data table of at least one associated user according to at least one sharable resource in the first sharable resource list.
  • the present application also provides a data query device, the device comprising:
  • a first query module is configured to respond to a resource query request of a user, read resource data in a resource data table of the user, and use the resource data in the resource data table read as first resource data;
  • a second query module is configured to read resource data in a shared data table of the user, and use the resource data in the shared data table read as second resource data, 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 reference count corresponding to the shared resource identifier, 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 configured to generate a resource display list based on the first resource data and the second resource data, and return the resource display list.
  • the present application also provides a server, the server comprising:
  • 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 execute any method described in the embodiments of the present application.
  • the embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement any method described in the embodiment of the present application when executed.
  • the embodiments of the present application further provide a computer program product, which includes computer executable instructions, and the computer executable instructions are used to implement any method described in the embodiments of the present application when executed.
  • FIG1 is a flow chart of a resource sharing method provided in Embodiment 1 of the present application.
  • FIG2 is a schematic diagram of a storage structure of a shared data table provided in Example 1 of the present application.
  • FIG3 is a flow chart of a resource sharing method provided in Embodiment 2 of the present application.
  • FIG4 is a flow chart of a resource sharing method provided in Embodiment 3 of the present application.
  • FIG5 is a flow chart of a resource sharing method provided in Embodiment 4 of the present application.
  • FIG6 is a flow chart of a resource sharing method provided in Embodiment 5 of the present application.
  • FIG7 is a flow chart of a resource sharing method provided in Embodiment 6 of the present application.
  • FIG8 is a flow chart of a data query method provided in Embodiment 7 of the present application.
  • FIG9 is a schematic diagram of a resource display list provided in Embodiment 7 of the present application.
  • FIG10 is a schematic diagram of the structure of a resource sharing device provided in Embodiment 8 of the present application.
  • Example 11 is a schematic diagram of the structure of a data query device provided in Example 9 of the present application.
  • FIG12 is a schematic diagram of the structure of a server provided in Embodiment 10 of the present application.
  • FIG1 is a flowchart of a resource sharing method provided in Embodiment 1 of the present application, which is applied to a scenario where resources are shared between users.
  • This embodiment can be executed by a server. As shown in FIG1 , this embodiment can include the following steps.
  • 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.
  • the user may be any user registered in the server.
  • a sharing level can be set for an individual user, and the user can increase the sharing level by performing specified operations; or, a sharing level can be set for an association between two users, and the sharing level can be updated based on the interaction between the two users.
  • 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.
  • the server monitors the sharing levels of multiple users. If it detects that a user's sharing level meets the standard, it 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 every user has. They refer to specific resources that can only be enjoyed after reaching a certain level.
  • the resources can be virtual resources.
  • the resources can include live broadcast prop resources such as skins, room entry special effects, and avatar frames; in a game scenario, the resources can include game prop resources such as skins, game special effects, and heroes.
  • General resources can be free resources, while shareable resources can be VIP resources.
  • each sharable resource may be represented by a resource identifier (eg, a resource identifier (IDentifier, ID), an item ID).
  • a resource identifier e.g, a resource identifier (IDentifier, ID), an item ID.
  • the sharable resource list of the user who currently meets the sharing level requirement is referred to as the first sharable resource list
  • the sharable resource list of other users different from the current user may be referred to as the second sharable resource list hereinafter.
  • 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.
  • the resource information table may also specify the main key Keyword (primary key):
  • Step 102 Determine a list of associated users of the current user.
  • the associated user list may include at least one associated user.
  • the associated user may be other users who have an interactive relationship with the current user and meet the set conditions.
  • the associated user may be a teammate of the current user.
  • the associated user may be a user who follows the current user or a user followed by the current user.
  • the associated user may be a friend user of the current user.
  • all users associated with the current user may be obtained, and users meeting set conditions may be selected from all users as associated users.
  • the associated user may also be another user specified by the user, for example, the associated user may be a user selected by the current user in his or her friend list, or a user searched by the current user.
  • Step 103 Obtain a shared data table of at least one associated user in the associated user list.
  • the shared data table (ShareTable) is a data table based on the Remote Dictionary Server (Redis) storage structure.
  • the Redis Hash structure can be used for data storage in the shared data table.
  • Redis Hash is an open source key-value storage database written in ANSI C language, compliant with the Berkeley Software Distribution (BSD) protocol, supporting the network, and can be based on memory, distributed, and optionally persistent. It also provides an application program interface (Application Program Interface, API) in multiple languages.
  • Hash is a Key-Value mapping data type supported by Redis, which is suitable for storing object type data.
  • each shared data table carries the user ID of the corresponding associated user
  • the shared data table may include a shared resource ID and a reference count corresponding to the shared resource ID, 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.
  • the storage structure of the shared data table can be shown in Figure 2.
  • 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.
  • PREFIX is a fixed prefix
  • $ ⁇ uid ⁇ is the unique uid of the user corresponding to the shared data table.
  • its field is the resource ID of the shared resource obtained by the uid
  • the value is the reference count, which indicates how many users can provide the corresponding shared resource for the current uid.
  • the reference count of item_id1 is 3, indicating 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.
  • Step 104 update a shared data table of at least one associated user according to at least one sharable resource in the first sharable resource list.
  • the associated shared data table can be updated according to the sharable resource list of the user who meets the standard, so that at least one associated user can share the sharable resources of the current user.
  • a resource identifier of at least one sharable resource in a first sharable resource list may be obtained, and each resource identifier may be matched in a shared data table of at least one associated user; for each shared data table, if a resource identifier is successfully matched in the shared data table, a reference count corresponding to the matched shared resource identifier in the shared data table is increased by 1; if another resource identifier fails to match in the shared data table, the resource identifier is added to the shared data table as a shared resource identifier, and the reference count corresponding to the resource identifier is marked as 1.
  • the sharable resources included in the first sharable resource list are item_id1, item_id2 and item_id8.
  • item_id1 and item_id2 can be matched, but item_id8 is not matched.
  • the reference count 3 of item_id1 can be incremented by 1 to obtain a reference count of 4
  • the reference count 1 of item_id2 can be incremented by 1 to obtain a reference count of 2.
  • Item_id8 is added to the shared data table, and the reference count of item_id8 is 1.
  • 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.
  • 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.
  • FIG3 is a flowchart of a resource sharing method provided in Embodiment 2 of the present application. Based on the above embodiments, this embodiment describes a scenario for detecting whether the sharing level meets the requirements and determining associated users. As shown in FIG3 , this embodiment may include the following steps.
  • Step 201 When the relationship level between a user and one or more related users in the relationship list of the user reaches a set relationship level threshold, it is determined that the sharing level of the user meets the requirement.
  • the relationship list may include a friend relationship list, and the relationship users are friend users who follow each other with the current user.
  • 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.:
  • Step 202 determine the related users whose relationship level reaches the set relationship level threshold as associated users, and generate an associated user list.
  • Step 203 Obtain a shared data table of at least one associated user in the associated user list.
  • 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.
  • Step 204 update at least one shared data table of the associated user according to at least one sharable resource in the first sharable resource list.
  • This embodiment illustrates an implementation scenario of sharing resources between users with an associated relationship.
  • the relationship level between two users reaches a set relationship level threshold
  • the shared data table of the other party 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.
  • FIG 4 is a flowchart of a resource sharing method provided in Example 3 of the present application. Based on the above embodiments, this embodiment describes another scenario for detecting whether the sharing level meets the requirements and determining associated users. As shown in Figure 4, this embodiment may include the following steps.
  • 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 requirement.
  • Step 302 taking users who have a specified association relationship with the user as associated users, and generating an associated user list.
  • Step 303 Obtain a shared data table of at least one associated user in the associated user list.
  • 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.
  • Step 304 update at least one sharable resource in the first sharable resource list.
  • 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 the user with a specified association relationship with the current user is directly used as an associated user.
  • 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.
  • FIG5 is a flowchart of a resource sharing method provided in Embodiment 4 of the present application. Based on any of the above embodiments, this embodiment describes the process of mutual resource sharing between users. As shown in FIG5 , this embodiment may include the following steps.
  • 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.
  • Step 402 Determine a list of associated users of the user.
  • Step 403 Obtain a shared data table of at least one associated user in the associated user list.
  • 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.
  • Step 404 update a shared data table of at least one associated user according to at least one sharable resource in the first sharable resource list.
  • Step 405 Obtain a second sharable resource list of at least one associated user.
  • Step 406 obtaining the shared data table of the current user.
  • Step 407 update the shared data table of the current user according to the second sharable resource list of at least one associated user.
  • the shared data table of the current user in addition to updating the shared data table of associated users according to the first sharable resource list of the current user, can also be updated according to the second sharable resource list of at least one associated user. For example, assuming that the friendship level of user A with user B and user C is upgraded to level 5, user A is the current user, and user B and user 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 as follows: As shown in Table 3 below:
  • the shared data table of user A shown in Table 3 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 shared data table of Table 4 is obtained:
  • the shared data table of user A shown in Table 4 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 the reference count of item_id3 is set to 1, so as to obtain the shared data table of Table 5:
  • the second sharable resource list of each associated user is updated.
  • 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.
  • FIG6 is a flowchart of a resource sharing method provided in Embodiment 5 of the present application. Based on any of the above embodiments, this embodiment describes the process of adding new shared resources. As shown in FIG6 , this embodiment may include the following steps.
  • Step 501 when it is detected that the sharing level of a user reaches the standard, a first sharable resource list of the user is obtained.
  • Step 502 Determine a list of associated users of the user.
  • Step 503 Obtain a shared data table of at least one associated user in the associated user list.
  • 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.
  • Step 504 update a shared data table of at least one associated user according to at least one sharable resource in the first sharable resource list.
  • 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.
  • the resource data table is a data table used to record user-owned resources, and each user-owned resource can be recorded in the resource data table in the form of a resource identifier.
  • the resource data table can be stored in a database, such as a MySQL database.
  • Step 506 Update the shared data table of at least one associated user according to the new shared resource.
  • the method for updating the shared data table of at least one associated user can refer to the description of step 104 in the above embodiment, 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 reference count corresponding to the resource identifier is set to 1.
  • the shared data table of at least one associated user is updated directly according to the newly added shared resource through Redis operation, without writing the newly added shared resource to One less resource data table associated with a user avoids the problem of write diffusion, simplifies the processing flow of newly added shared resources, improves the maintenance efficiency of shared resources, and thus better improves service performance.
  • FIG7 is a flowchart of a resource sharing method provided in Embodiment 6 of the present application. Based on any of the above embodiments, this embodiment describes the process of recycling shared resources. As shown in FIG7 , this embodiment may include the following steps.
  • Step 601 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.
  • Step 602 Determine a list of associated users of the user.
  • Step 603 Obtain a shared data table of at least one associated user in the associated user list.
  • 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.
  • Step 604 update a shared data table of at least one associated user according to at least one sharable resource in the first sharable resource list.
  • 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 at least one associated user based on the resource identifier of the invalid resource, and the reference count found is reduced by 1.
  • the invalid resource refers to a resource that cannot be shared. If the resource has been shared, it is necessary to recycle the resource. In this embodiment, when recycling resources, the reference count in the shared data table is directly updated. For example, the resource identifier of the invalid resource can be searched in the shared data table of at least one associated user, and the reference count in the found data record is reduced by 1.
  • the reference count in the data record where item_id1 is located may be updated from 3 to 2.
  • 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.
  • 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.
  • all the user's sharable resources can be treated as invalid resources, and each invalid resource can be used one by one to update the shared data table of at least one associated user.
  • the following method can be used to detect failed resources: when a user When the relationship level of one or more associated users is lower than the set relationship level threshold, each sharable resource of the user is regarded as an invalid resource.
  • 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.
  • Each sharable resource has a usage period, and if the usage period is exceeded, the corresponding shared resource expires.
  • 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.
  • expired sharable resources may be used as invalid resources, and the shared data table of at least one associated user may be updated using the invalid resources.
  • Step 606 When a reference count with a value of 0 appears in the shared data table, the resource record corresponding to the reference count with a value of 0 is deleted from the shared data table.
  • the resource record containing the reference count with a value of 0 is deleted from the shared data table.
  • FIG8 is a flowchart of a method for data query provided in Embodiment 7 of the present application. Compared with the aforementioned embodiments, this embodiment focuses on the scenario of reading data, while the aforementioned embodiments focus on the scenario of writing data. As shown in FIG8 , this embodiment may include the following steps.
  • Step 701 In response to a resource query request from a user, resource data in a resource data table of the user is read, and the resource data in the resource data table read is used as first resource data.
  • the resource query request carries the user ID of the 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, and the read resource data can be used as the first resource data.
  • the resource data table is a data table for recording the user's own resources, and each owned resource can be recorded in the resource data table in the form of a resource ID.
  • the first resource data can include the resource ID of the current user's own resources.
  • Step 702 read the resource data in the shared data table of the user, and use the resource data in the shared data table read as the second resource data.
  • 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 reference count corresponding to the shared resource identifier.
  • 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 shared data table corresponding to the user ID can also be searched in Redis according to the user ID, and the resource data in the shared data table can be read, and the read resource data can be used as the second resource data.
  • the second resource data can include the resource ID of the resource shared by the current user and the reference count corresponding to each resource ID.
  • Step 703 Generate a resource display list based on the first resource data and the second resource data, and return the resource display list.
  • 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.
  • the resource display list may include each resource identifier in the first resource data and the reference count corresponding to each resource identifier, and each resource identifier in the second resource data and the reference count corresponding to each resource identifier.
  • Reference count If the resource identifier is a code type, the resource identifier can be converted into a resource name and then displayed, as shown in FIG9 , where the owned resource is derived from the first resource data and the shared resource is derived from the second resource data.
  • this embodiment can greatly improve the service performance and reduce the database pressure in high concurrency scenarios.
  • FIG10 is a schematic diagram of the structure of a resource sharing device provided in Embodiment 8 of the present application, which may include the following modules.
  • An associated user list determination module 802 is configured to determine an associated user list of the user
  • a first shared data table acquisition module 803 is configured to acquire a shared data table of at least one 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 reference count corresponding to the shared resource identifier, 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;
  • the first shared data table updating module 804 is configured to update the shared data table of at least one associated user according to at least one sharable resource in the first sharable resource list.
  • the first shared data table updating module 804 is configured to:
  • the reference count corresponding to the matched shared resource identifier is increased by 1;
  • the resource identifier is added to the shared data table as a shared resource identifier, and the reference count of the resource identifier is marked as 1.
  • the device further includes a first compliance detection module configured to:
  • the associated user list determination module 802 is configured to:
  • the related users whose relationship levels reach the set relationship level threshold are determined as associated users, and an associated user list is generated.
  • the device further includes a second compliance detection module configured to:
  • the associated user list determination module 802 is configured to:
  • Users having a specified association relationship with the user are taken as associated users, and an associated user list is generated.
  • the device may further include:
  • a second sharable resource list acquisition module configured to acquire a second sharable resource list of at least one associated user
  • a second shared data table acquisition module configured to acquire the shared data table of the user
  • the second shared data table updating module is configured to update the shared data table of the user according to the second sharable resource list of at least one associated user.
  • the device may further include:
  • a resource data table writing module configured to write a new shared resource into the resource data table of the user when the user obtains the new shared resource
  • the newly added resource writing module is configured to update the shared data table of at least one associated user according to the new shared resource.
  • the device may further include:
  • the resource recovery module is configured to search in a shared data table of at least one 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 a reference count with a value of 0 appears in the shared data table, the resource record corresponding to the reference count with a value of 0 is deleted in the shared data table.
  • the failed resource is detected in the following manner:
  • each shareable resource of the user is regarded as an invalid resource
  • the expired sharable resource is regarded as an invalid resource
  • each sharable resource of the user is regarded as an invalid resource.
  • a resource sharing device provided in an embodiment of the present application can execute a resource sharing method provided in any embodiment of the present application, and has functional modules and effects corresponding to the execution method.
  • FIG11 is a schematic diagram of the structure of a data query device provided in Embodiment 9 of the present application, which may include the following modules.
  • the first query module 901 is configured to respond to a resource query request of a user, read resource data in a resource data table of the user, and use the resource data in the resource data table read as first resource data;
  • the second query module 902 is configured to read the resource data in the shared data table of the user, and use the resource data in the shared data table read 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 reference count corresponding to the shared resource identifier, 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 903 is configured to generate a resource display list based on the first resource data and the second resource data, and return the resource display list.
  • a data query device provided in an embodiment of the present application can execute a data query method provided in an embodiment of the present application, and has functional modules and effects corresponding to the execution method.
  • FIG12 shows a schematic diagram of the structure of a server 10 that can be used to implement the method embodiment of the present application.
  • the server 10 includes at least one processor 11, and a storage device that is connected to the at least one processor 11 in communication, 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 11, and the processor 11 can perform a variety of appropriate actions and processes according to the computer program stored in the ROM 12 or the computer program loaded from the storage unit 18 to the RAM 13.
  • the RAM 13 a variety of programs and data required for the operation of the server 10 can also be stored.
  • the method in any embodiment of the present application may be implemented as a computer program. It is tangibly contained in a computer-readable storage medium, such as a storage unit 18.
  • the storage medium may be a non-transitory storage medium.
  • 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, the method in any embodiment of the present application described above may be executed.
  • the method in any embodiment of the present application may be implemented as a computer program product, which includes computer executable instructions, which are used to execute the method in any embodiment of the present application described above when executed.

Landscapes

  • Engineering & Computer Science (AREA)
  • Signal Processing (AREA)
  • Multimedia (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Business, Economics & Management (AREA)
  • Computer Security & Cryptography (AREA)
  • General Business, Economics & Management (AREA)
  • Databases & Information Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

A resource sharing method and apparatus, a data query method and apparatus, and a server. The resource sharing method comprises: when it is detected that the sharing level of a user reaches a standard, acquiring a first sharable-resource list of the user (101); determining an associated-user list of the user (102); acquiring a sharing data table of at least one associated user in the associated-user list (103), wherein the sharing data table is a data table based on a remote dictionary service (Redis) storage structure, the sharing data table carries a user identifier, and the sharing data table comprises a sharing resource identifier and a reference count corresponding to the sharing resource identifier, which reference count is used for recording the number of users that share to the user identifier a sharing resource corresponding to the sharing resource identifier; and updating the sharing data table of the at least one associated user according to at least one sharable resource in the first sharable-resource list (104).

Description

资源共享及数据查询的方法、装置和服务器Resource sharing and data query method, device and server
本申请要求在2022年11月02日提交中国专利局、申请号为202211363501.7的中国专利申请的优先权,该申请的全部内容通过引用结合在本申请中。This application claims priority to the Chinese patent application filed with the China Patent Office on November 2, 2022, with application number 202211363501.7, the entire contents of which are incorporated by reference into this application.
技术领域Technical Field
本申请涉及数据处理技术领域,例如涉及一种资源共享的方法、一种数据查询的方法、一种资源共享的装置、一种数据查询的装置、一种服务器、一种计算机可读存储介质以及一种计算机程序产品。The present application relates to the field of data processing technology, for example, 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 technique
随着互联网技术的发展,出现了用户之间共享用户资源的需求场景,当用户之间满足一定条件时,可以互相使用对方拥有的一些特殊虚拟资产。例如,在游戏场景中当用户的重要人物(Very Important Person,VIP)等级达到一定级别后,可以把自己的一些游戏道具共享给同场比赛的其他队友使用。又如,在直播场景中,当好友关系等级达到一定级别之后,可以把自己的一些道具(头像框、皮肤卡以及进房特效等)共享给好友使用,也可以使用好友拥有的一些道具等。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 scene, when the user's Very Important Person (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 scene, 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.
在相关技术中,实现用户之间共享用户资源的方式如下:In related technologies, the method of sharing user resources between users is as follows:
方式一:当用户获得一种可以共享的资源时,首先将该资源写入用户自己的物品表里面,然后检查自己是否有符合条件的共享好友,如果有则将该资源的物品信息也写入该共享好友的物品表中,这样用户在查询自己可用的物品信息时,只需要查询自己名下的物品表即可。但这种方式存在写扩散问题,即,如果用户有多个符合条件的共享好友,则用户在获得可共享的资源时需要将该资源的信息写入每个共享好友的物品表中,使得该资源的信息需要写入多份(取决于有多少个共享好友),虽然这样能使得用户在查询自己可用的物品列表时流程得到最简,但也极大地造成数据冗余,出现用户的物品表的数据量增大、查询较慢等问题,同时也直接导致了共享资源的回收麻烦等问题。例如,当一个共享的物品由多个不同的共享好友共享给用户时,比如B、C和D都拥有同一个物品且都共享给A,即便A和B解除共享关系,A也依然可以从C、D处共享使用该物品,因此此时A名下的共享物品信息不能清除,为此则又不得不对共享获得的物品再额外记录该物品可从哪些用户处共享得到。从而使得数据存储和共享特权回收过程非常复杂。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 in 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, such as 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 the item with 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.
方式二:用户获得一种可以共享的资源时,仅写入自己的物品表,然后用 户查询自己可用的物品信息时,先查自己名下的物品表,再查下是否有符合条件的共享好友,如果有再查共享好友名下可共享的物品。该方式与方式一的区别在于,该方式不会把共享的资源写到共享好友的物品表中,使得更新共享物品的流程很简单并且省去了资源回收流程。但这种方式存在读扩散问题,即,用户在查询自己可用的物品列表时,除了查自己名下的物品,还需要查是否有符合条件的共享好友,如果有则继续查询每个共享好友名下是否有可以共享的资源。从而,任何用户每次查询可用物品列表时至少需要查3次数据库(无符合条件的共享好友时),至多需要查4次(有符合条件共享好友时)。而一般用户查询自己物品列表的频率都会远远高于自己物品表的更新频率,因此这种方案下如果用户量大且拉取用户物品信息频繁,就可能导致数据库负载过高以及服务卡顿等问题。Method 2: When a user obtains a resource that can be shared, he only writes his own item table and then uses When a 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 items that can be shared 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 a read diffusion problem, that is, when a 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, and if so, he continues to check whether there are any resources that can be shared 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) each time he queries the available item list. The frequency of users generally querying their own item lists is much higher than the update frequency of their own item tables. Therefore, if the number of users is large and the user item information is frequently pulled under this solution, it may cause problems such as excessive database load and service jams.
发明内容Summary of the invention
本申请提供了一种资源共享及数据查询的方法、装置和服务器,以解决相关技术中进行用户间的资源共享时存在的写扩散、读扩散以及数据库操作频繁的问题。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 related art when resources are shared among users.
本申请实施例提供了一种资源共享的方法,所述方法包括:The present application provides a resource sharing method, the method comprising:
当检测到用户的共享等级达标时,获取所述用户的第一可共享资源列表;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;
获取所述关联用户列表中至少一个关联用户的共享数据表,其中,所述共享数据表为基于Redis存储结构的数据表,所述共享数据表携带用户标识,所述共享数据表中包括共享资源标识以及共享资源标识对应的引用计数,所述引用计数用于记录对该用户标识分享所述共享资源标识对应的共享资源的用户的数量;Obtaining a shared data table of at least one 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 reference count corresponding to the shared resource identifier, 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;
根据所述第一可共享资源列表中的至少一种可共享资源更新至少一个关联用户的共享数据表。At least one shared data table of the associated user is updated according to at least one sharable resource in the first sharable resource list.
本申请实施例还提供了一种数据查询的方法,所述方法包括:The present application also provides a method for querying data, the method comprising:
响应于用户的资源查询请求,读取所述用户的资源数据表中的资源数据,并将读取到的资源数据表中的资源数据作为第一资源数据;In response to a resource query request from a user, resource data in a resource data table of the user is read, and the resource data in the resource data table read is used as first resource data;
读取所述用户的共享数据表中的资源数据,并将读取到的共享数据表中的资源数据作为第二资源数据,其中,所述共享数据表为基于Redis存储结构的数据表,所述共享数据表携带用户标识,所述共享数据表中包括共享资源标识以及共享资源标识对应的引用计数,所述引用计数用于记录对该用户标识分享所 述共享资源标识对应的共享资源的用户的数量;Read the resource data in the shared data table of the user, and use the resource data in the shared data table read 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, the shared data table includes the shared resource identifier and the reference count corresponding to the shared resource identifier, and the reference count is used to record the shared resource identifier of the user. the number of users sharing the resource corresponding to the shared resource 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.
本申请实施例还提供了一种资源共享的装置,所述装置包括:The embodiment of the present application also provides a resource sharing device, the device comprising:
第一可共享资源列表获取模块,设置为当检测到用户的共享等级达标时,获取所述用户的第一可共享资源列表;A first sharable resource list acquisition module, configured to acquire a first sharable resource list of the user when detecting that the sharing level of the user meets the requirement;
关联用户列表确定模块,设置为确定所述用户的关联用户列表;An associated user list determination module, configured to determine an associated user list of the user;
第一共享数据表获取模块,设置为获取所述关联用户列表中至少一个关联用户的共享数据表,其中,所述共享数据表为基于Redis存储结构的数据表,所述共享数据表携带用户标识,所述共享数据表中包括共享资源标识以及共享资源标识对应的引用计数,所述引用计数用于记录对该用户标识分享所述共享资源标识对应的共享资源的用户的数量;A first shared data table acquisition module is configured to acquire a shared data table of at least one 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 reference count corresponding to the shared resource identifier, 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;
第一共享数据表更新模块,设置为根据所述第一可共享资源列表中的至少一种可共享资源更新至少一个关联用户的共享数据表。The first shared data table updating module is configured to update the shared data table of at least one associated user according to at least one sharable resource in the first sharable resource list.
本申请实施例还提供了一种数据查询的装置,所述装置包括:The present application also provides a data query device, the device comprising:
第一查询模块,设置为响应于用户的资源查询请求,读取所述用户的资源数据表中的资源数据,并将读取到的资源数据表中的资源数据作为第一资源数据;A first query module is configured to respond to a resource query request of a user, read resource data in a resource data table of the user, and use the resource data in the resource data table read as first resource data;
第二查询模块,设置为读取所述用户的共享数据表中的资源数据,并将读取到的共享数据表中的资源数据作为第二资源数据,其中,所述共享数据表为基于Redis存储结构的数据表,所述共享数据表携带用户标识,所述共享数据表中包括共享资源标识以及共享资源标识对应的引用计数,所述引用计数用于记录对该用户标识分享所述共享资源标识对应的共享资源的用户的数量;A second query module is configured to read resource data in a shared data table of the user, and use the resource data in the shared data table read as second resource data, 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 reference count corresponding to the shared resource identifier, 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 configured to generate a resource display list based on the first resource data and the second resource data, and return the resource display list.
本申请实施例还提供了一种服务器,所述服务器包括:The present application also provides a server, the server comprising:
至少一个处理器;以及at least one processor; and
与所述至少一个处理器通信连接的存储器;其中,a memory communicatively connected to the at least one processor; wherein,
所述存储器存储有可被所述至少一个处理器执行的计算机程序,所述计算机程序被所述至少一个处理器执行,以使所述至少一个处理器能够执行本申请实施例中任一所述的方法。 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 execute any method described in the embodiments of the present application.
本申请实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机指令,所述计算机指令用于使处理器执行时实现本申请实施例中任一所述的方法。The embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement any method described in the embodiment of the present application when executed.
本申请实施例还提供了一种计算机程序产品,所述计算机程序产品包括计算机可执行指令,所述计算机可执行指令在被执行时用于实现本申请实施例中任一所述的方法。The embodiments of the present application further provide a computer program product, which includes computer executable instructions, and the computer executable instructions are used to implement any method described in the embodiments of the present application when executed.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
图1是本申请实施例一提供的一种资源共享的方法的流程图;FIG1 is a flow chart of a resource sharing method provided in Embodiment 1 of the present application;
图2是本申请实施例一提供的一种共享数据表的存储结构的示意图;FIG2 is a schematic diagram of a storage structure of a shared data table provided in Example 1 of the present application;
图3是本申请实施例二提供的一种资源共享的方法的流程图;FIG3 is a flow chart of a resource sharing method provided in Embodiment 2 of the present application;
图4是本申请实施例三提供的一种资源共享的方法的流程图;FIG4 is a flow chart of a resource sharing method provided in Embodiment 3 of the present application;
图5是本申请实施例四提供的一种资源共享的方法的流程图;FIG5 is a flow chart of a resource sharing method provided in Embodiment 4 of the present application;
图6是本申请实施例五提供的一种资源共享的方法的流程图;FIG6 is a flow chart of a resource sharing method provided in Embodiment 5 of the present application;
图7是本申请实施例六提供的一种资源共享的方法的流程图;FIG7 is a flow chart of a resource sharing method provided in Embodiment 6 of the present application;
图8是本申请实施例七提供的一种数据查询的方法的流程图;FIG8 is a flow chart of a data query method provided in Embodiment 7 of the present application;
图9是本申请实施例七提供的资源展示列表的示意图;FIG9 is a schematic diagram of a resource display list provided in Embodiment 7 of the present application;
图10是本申请实施例八提供的一种资源共享的装置的结构示意图;FIG10 is a schematic diagram of the structure of a resource sharing device provided in Embodiment 8 of the present application;
图11是本申请实施例九提供的一种数据查询的装置的结构示意图;11 is a schematic diagram of the structure of a data query device provided in Example 9 of the present application;
图12是本申请实施例十提供的一种服务器的结构示意图。FIG12 is a schematic diagram of the structure of a server provided in Embodiment 10 of the present application.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行描述,所描述的实施例仅仅是本申请一部分的实施例,而不是全部的实施例。The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application. The described embodiments are only part of the embodiments of the present application, rather than all the embodiments.
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。这样使用的数据在适当情况下可以互换,以便这里描述的本申请的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于列出的那些步骤或单元,而是可包括没有列出的或对于这些过程、方法、产品或设备固有的其它步骤或单 元。The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. The numbers used in this way are interchangeable where appropriate so that the embodiments of the application described herein can be implemented in orders other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or apparatus that includes a series of steps or units is not necessarily limited to those listed steps or units, but may include other steps or units that are not listed or inherent to these processes, methods, products or apparatuses. Yuan.
实施例一Embodiment 1
图1为本申请实施例一提供的一种资源共享的方法的流程图,应用于用户之间进行资源共享的场景,本实施例可以由服务器执行,如图1所示,本实施例可以包括如下步骤。FIG1 is a flowchart of a resource sharing method provided in Embodiment 1 of the present application, which is applied to a scenario where resources are shared between users. This embodiment can be executed by a server. As shown in FIG1 , this embodiment can include the following steps.
步骤101,当检测到用户的共享等级达标时,获取该用户的第一可共享资源列表。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.
其中,该用户可以为在服务器中注册的任一用户。The user may be any user registered in the server.
该共享等级根据应用场景的不同可以设置不同类型的共享等级,例如,可以针对用户个人设置共享等级,用户通过执行指定操作来提升共享等级;或者,还可以针对两用户之间的关联关系设置共享等级,该共享等级可以根据两用户之间的互动行为进行更新。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 sharing level can be set for an association between two users, and the sharing level can be updated based on the interaction between the two users.
上述的达标,可以为达到预设条件,而该预设条件可以根据应用场景的不同而不同。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.
服务器通过对多个用户的共享等级进行监测,若监测到一个用户的共享等级达标时,则获取该用户的可共享资源列表,其中,可共享资源列表中包括一种或多种可共享资源,该可共享资源区别于每个用户都有的通用资源,是指达到一定等级后才能享有的特定资源。示例性地,该资源可以是虚拟资源,例如在直播场景下,资源可以包括皮肤、进房特效、头像框等直播道具资源;在游戏场景下,资源可以包括皮肤、游戏特效、英雄等游戏道具资源。通用资源例如可以是免费的资源,而可共享资源可以是VIP资源。The server monitors the sharing levels of multiple users. If it detects that a user's sharing level meets the standard, it 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 every user has. They refer to specific resources that can only be enjoyed after reaching a certain level. Exemplarily, the resources can be virtual resources. For example, in a live broadcast scenario, the resources can include live broadcast prop resources such as skins, room entry special effects, and avatar frames; in a game scenario, the resources can include game prop resources such as skins, game special effects, and heroes. General resources can be free resources, while shareable resources can be VIP resources.
在实现时,在可共享资源列表中,每个可共享资源可以使用资源标识(例如资源标识(IDentifier,ID)、物品ID)进行表示。During implementation, in the sharable resource list, each sharable resource may be represented by a resource identifier (eg, a resource identifier (IDentifier, ID), an item ID).
为了便于区分,本实施例将当前共享等级达标的用户的可共享资源列表称为第一可共享资源列表,而下文中区别于当前用户的其他用户的可共享资源列表可以称为第二可共享资源列表。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.
在一种实现中,当需要获得第一可共享资源列表时,可以获得当前用户的所有资源,从所有资源中选取可共享资源组成第一可共享资源列表。示例性的,在服务器中可以针对每个资源配置对应的资源信息表,该资源信息表可缓存于内存中,如下表1所示,该资源信息表中可以包括资源ID、资源类型、资源名称、资源图标、是否可共享等字段,除此以外,资源信息表中还可以指定主关 键字(primary key):
In one implementation, when it is necessary to obtain the first sharable resource list, all resources of the current user may be obtained, and sharable resources may be selected from all resources to form the first sharable resource list. Exemplarily, 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 the main key Keyword (primary key):
表1Table 1
根据每个资源的is_shareable字段的值可以判定该资源是否为可共享资源,若is_shareable=1表示该资源为可共享资源,若is_shareable=0表示该资源为不可共享资源。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.
步骤102,确定当前用户的关联用户列表。Step 102: Determine a list of associated users of the current user.
其中,该关联用户列表中可以包括至少一个关联用户,在一种实施例中,该关联用户可以为与当前用户存在交互关系、且符合设定条件的其他用户,例如,在游戏场景中该关联用户可以为当前用户的队友,在直播场景中关联用户可以是与当前用户互粉的用户或当前用户关注的用户,在即时通讯场景中关联用户可以是当前用户的好友用户。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.
在一种实现中,可以获取与当前用户存在关联关系的所有用户,从该所有用户中选择符合设定条件的用户作为关联用户。In one implementation, all users associated with the current user may be obtained, and users meeting set conditions may be selected from all users as associated users.
在其他实施例中,关联用户还可以是用户指定的其他用户,例如,关联用户为当前用户在其好友列表中选择的用户,或者,当前用户搜索得到的用户。In other embodiments, the associated user may also be another user specified by the user, for example, the associated user may be a user selected by the current user in his or her friend list, or a user searched by the current user.
另一方面,如果当前用户没有符合设定条件的关联用户,则结束流程。On the other hand, if the current user has no associated users that meet the set conditions, the process ends.
步骤103,获取该关联用户列表中至少一个关联用户的共享数据表。Step 103: Obtain a shared data table of at least one associated user in the associated user list.
其中,该共享数据表(ShareTable)为基于远程字典服务(Remote Dictionary Server,Redis)存储结构的数据表,在共享数据表中可以采用Redis Hash结构来进行数据存储,其中,Redis Hash是一个开源的使用ANSI C语言编写、遵守伯克利软件套件(Berkeley Software Distribution,BSD)协议、支持网络、可基于内存、分布式、可选持久性的键值对(Key-Value)存储数据库,并提供多种语言的应用程序接口(Application Program Interface,API)。而Hash是Redis支持的一种Key-Value映射数据类型,适合用于存储对象类型的数据。 The shared data table (ShareTable) is a data table based on the Remote Dictionary Server (Redis) storage structure. The Redis Hash structure can be used for data storage in the shared data table. Redis Hash is an open source key-value storage database written in ANSI C language, compliant with the Berkeley Software Distribution (BSD) protocol, supporting the network, and can be based on memory, distributed, and optionally persistent. It also provides an application program interface (Application Program Interface, API) in multiple languages. Hash is a Key-Value mapping data type supported by Redis, which is suitable for storing object type data.
在本实施例中,每个共享数据表携带对应的关联用户的用户标识,且在共享数据表中可以包括共享资源标识以及共享资源标识对应的引用计数。其中,该引用计数用于记录对该用户标识分享该共享资源标识对应的共享资源的用户的数量。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 reference count corresponding to the shared resource ID, 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.
例如,共享数据表的存储结构可以如图2所示,在图2中,共享数据表的key格式为:PREFIX_${uid},其中PREFIX为固定的前缀,${uid}为该共享数据表对应的用户的唯一uid。对于每个共享数据表,其字段(field)为该uid获得的共享资源的资源ID,值(value)为引用计数,该引用计数表示有多少个用户可为当前uid提供对应的共享资源,比如在图2中,item_id1的引用计数为3,表示能为当前uid提供item_id1的用户数量为3,即,有3个用户为当前uid共享item_id1这个资源。For example, the storage structure of the shared data table can be shown in Figure 2. In Figure 2, 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, the reference count of item_id1 is 3, indicating 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.
步骤104,根据该第一可共享资源列表中的至少一种可共享资源更新至少一个关联用户的共享数据表。Step 104: update a shared data table of at least one associated user according to at least one sharable resource in the first sharable resource list.
在对共享数据表的维护管理上,如果有用户的共享等级达标,则可以根据该达标的用户的可共享资源列表来更新存在关联的共享数据表,使得至少一个关联用户可以共享当前用户的可共享资源。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 at least one associated user can share the sharable resources of the current user.
在一种实现中,可以获取第一可共享资源列表中的至少一种可共享资源的资源标识,并在至少一个关联用户的共享数据表中匹配每个资源标识;对于每个共享数据表,如果一个资源标识在该共享数据表中匹配成功,则将该共享数据表中匹配上的共享资源标识对应的引用计数加1;若另一个资源标识在该共享数据表中匹配失败,则在该共享数据表中新增该资源标识作为共享资源标识,并标记该资源标识对应的引用计数为1。In one implementation, a resource identifier of at least one sharable resource in a first sharable resource list may be obtained, and each resource identifier may be matched in a shared data table of at least one associated user; for each shared data table, if a resource identifier is successfully matched in the shared data table, a reference count corresponding to the matched shared resource identifier in the shared data table is increased by 1; if another resource identifier fails to match in the shared data table, the resource identifier is added to the shared data table as a shared resource identifier, and the reference count corresponding to the resource identifier is marked as 1.
例如,第一可共享资源列表中包含的可共享资源为item_id1、item_id2和item_id8,则对图2的共享数据表进行更新时,item_id1和item_id2能够匹配上,但item_id8没有匹配上,则可以将item_id1的引用计数3自增1得到引用计数为4,将item_id2的引用计数1自增1得到引用计数为2,并在该共享数据表中增加item_id8,item_id8的引用计数为1。For example, the sharable resources included in the first sharable resource list are item_id1, item_id2 and item_id8. When the shared data table of Figure 2 is updated, item_id1 and item_id2 can be matched, but item_id8 is not matched. In this case, the reference count 3 of item_id1 can be incremented by 1 to obtain a reference count of 4, and the reference count 1 of item_id2 can be incremented by 1 to obtain a reference count of 2. Item_id8 is added to the shared data table, and the reference count of item_id8 is 1.
在本实施例中,通过共享数据表来维护每个用户获得的共享资源,在该共享数据表中记录每种共享资源的引用计数,通过该引用计数来记录能为用户提供当前共享资源的用户数量,当需要进行资源共享时,直接通过引用计数实现共享资源的管理,而无需将共享资源写入至少一个关联用户的资源数据表中,不会给至少一个关联用户的资源数据表增加额外数据,减少了数据冗余和表间耦合,避免出现写扩散问题。后续基于共享资源的查询、更新、回收等操作都基于该引用计数实现,使得共享资源的管理尽可能简洁高效,降低了用户间的 共享资源的维护成本,从而提升了服务性能。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 achieved through the reference count, without writing the shared resources into the resource data table of at least one associated user, and no additional data is added to the resource data table of at least one 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 implemented based on the reference count, making the management of shared resources as simple and efficient as possible, reducing the communication between users. The maintenance cost of shared resources is reduced, thereby improving service performance.
示例性地,本实施例的共享数据表是基于Redis存储结构的数据表,相比于对数据库的读写操作而言,Redis的读写效率更高,减低了数据库的读写次数,在高并发场景下能极大的提升服务性能,减轻数据库的压力。Exemplarily, 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.
在进行资源查询时,进行一次数据库查询(在资源数据表中进行查询)和一次Redis查询(在共享数据表中查询)即可,无需分别对至少一个关联用户的资源数据表进行查询,输入/输出(Input/Output,I/O)操作次数减少,避免读扩散问题,有效地减少了数据库操作的次数,从而降低数据库负载,提升服务响应效率。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 at least one associated user separately. The number of input/output (I/O) 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.
实施例二Embodiment 2
图3为本申请实施例二提供的一种资源共享的方法的流程图,本实施例在上述实施例的基础上,对检测共享等级达标和确定关联用户的一种场景进行说明,如图3所示,本实施例可以包括如下步骤。FIG3 is a flowchart of a resource sharing method provided in Embodiment 2 of the present application. Based on the above embodiments, this embodiment describes a scenario for detecting whether the sharing level meets the requirements and determining associated users. As shown in FIG3 , this embodiment may include the following steps.
步骤201,当用户与该用户的关系列表中的其中一个或多个关系用户的关系等级达到设定关系等级阈值,则判定该用户的共享等级达标。Step 201: When the relationship level between a user and one or more related users in the relationship list of the user reaches a set relationship level threshold, it is determined that the sharing level of the user meets the requirement.
示例性地,该关系列表可以包括好友关系列表,则关系用户为与当前用户互相关注的好友用户。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.
在实现时,在服务器中,对于每个关系可以维护一个关系表,如表2所示,该关系表中可以包括关系id、关系发起方uid、关系接受方uid、关系等级、关系创建时间等字段:
In the 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.:
表2Table 2
步骤202,将该关系等级达到设定关系等级阈值的关系用户确定为关联用户,生成关联用户列表。Step 202: determine the related users whose relationship level reaches the set relationship level threshold as associated users, and generate an associated user list.
例如,假设用户A和用户B为好友关系,在两者的好友关系等级升级至5 级(假设5级为设定好友等级)时,可以判定用户A和用户B的共享等级达标。如果此时用户A为当前用户,则用户B为用户A的关联用户。如果此时用户B为当前用户,则用户A为用户B的关联用户。For example, suppose user A and user B are friends. When their friendship level is upgraded to level 5 When the user A and user B reach the level of friend (assuming level 5 is the set friend level), it can be determined that the sharing level of user A and user B meets 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.
又如,假设用户A分别与用户B、用户C以及用户D的好友关系等级均升级至5级,用户A为当前用户,则用户B、用户C以及用户D均为用户A的关联用户,关联用户列表中包含用户B、用户C以及用户D。For another example, assuming that the friendship levels of user A with user B, user C, and user D are all upgraded to level 5, and user A is the current user, then user B, user C, and user D are all associated users of user A, and the associated user list includes user B, user C, and user D.
步骤203,获取关联用户列表中至少一个关联用户的共享数据表。Step 203: Obtain a shared data table of at least one associated user in the associated user list.
其中,该共享数据表为基于Redis存储结构的数据表,该共享数据表携带用户标识,该共享数据表中可以包括共享资源标识以及对应的引用计数,该引用计数用于记录对该用户标识分享当前共享资源标识对应的共享资源的用户的数量。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.
步骤204,根据该第一可共享资源列表中的至少一种可共享资源更新至少一个关联用户的共享数据表。Step 204: update at least one shared data table of the associated user according to at least one sharable resource in the first sharable resource list.
本实施例对存在关联关系的用户间共享资源的实现场景进行说明,当两用户之间的关系等级达到设定关系等级阈值时,则可以根据该两用户的可共享资源列表更新对方的共享数据表,实现两用户间共享资源的共享和管理,简化了用户间共享资源的管理难度,提升服务性能。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 shared data table of the other party 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.
实施例三Embodiment 3
图4为本申请实施例三提供的一种资源共享的方法的流程图,本实施例在上述实施例的基础上,对检测共享等级达标和确定关联用户的另一种场景进行说明,如图4所示,本实施例可以包括如下步骤。Figure 4 is a flowchart of a resource sharing method provided in Example 3 of the present application. Based on the above embodiments, this embodiment describes another scenario for detecting whether the sharing level meets the requirements and determining associated users. As shown in Figure 4, this embodiment may include the following steps.
步骤301,当用户的共享等级达到设定等级阈值时,则判定所述用户的共享等级达标。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 requirement.
步骤302,将与所述用户存在指定关联关系的用户作为关联用户,生成关联用户列表。Step 302: taking users who have a specified association relationship with the user as associated users, and generating an associated user list.
步骤303,获取所述关联用户列表中至少一个关联用户的共享数据表。Step 303: Obtain a shared data table of at least one associated user in the associated user list.
其中,所述共享数据表为基于Redis存储结构的数据表,所述共享数据表携带用户标识,所述共享数据表中包括共享资源标识以及对应的引用计数,所述引用计数用于记录对该用户标识分享所述共享资源标识对应的共享资源的用户的数量。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.
步骤304,根据所述第一可共享资源列表中的至少一种可共享资源更新至少 一个关联用户的共享数据表。Step 304: update at least one sharable resource in the first sharable resource list. A shared data table associated with users.
本实施例与上述实施例的区别在于:本实施例无需对两个用户的关系等级进行判断,而是在单个用户的共享等级达到设定等级阈值时,则判定该用户的共享等级达标,直接将与当前用户存在指定关联关系的用户作为关联用户。其中,该指定关联关系可以根据不同的应用场景做不同的设定,例如,在游戏场景中,该指定关联关系可以为队友关系,也就是说在一个游戏队伍里,如果有一个游戏用户的游戏等级达到设定等级阈值,则可以将该游戏用户的可共享资源共享给其他队友。实现具有指定关联关系的用户间的共享资源的共享和管理,简化了共享资源的管理难度,提升服务性能。The difference between this embodiment and the above 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 the user with 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.
实施例四Embodiment 4
图5为本申请实施例四提供的一种资源共享的方法的流程图,本实施例在上述任一实施例的基础上,对用户间进行资源相互共享的过程进行说明,如图5所示,本实施例可以包括如下步骤。FIG5 is a flowchart of a resource sharing method provided in Embodiment 4 of the present application. Based on any of the above embodiments, this embodiment describes the process of mutual resource sharing between users. As shown in FIG5 , this embodiment may include the following steps.
步骤401,当检测到用户的共享等级达标时,获取该用户的第一可共享资源列表。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.
步骤402,确定该用户的关联用户列表。Step 402: Determine a list of associated users of the user.
步骤403,获取关联用户列表中至少一个关联用户的共享数据表。Step 403: Obtain a shared data table of at least one associated user in the associated user list.
其中,该共享数据表为基于Redis存储结构的数据表,共享数据表携带用户标识,共享数据表中包括共享资源标识以及对应的引用计数,该引用计数用于记录对该用户标识分享当前共享资源标识对应的共享资源的用户的数量。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.
步骤404,根据第一可共享资源列表中的至少一种可共享资源更新至少一个关联用户的共享数据表。Step 404: update a shared data table of at least one associated user according to at least one sharable resource in the first sharable resource list.
步骤405,获取至少一个关联用户的第二可共享资源列表。Step 405: Obtain a second sharable resource list of at least one associated user.
步骤406,获取当前用户的共享数据表。Step 406, obtaining the shared data table of the current user.
步骤407,分别根据至少一个关联用户的第二可共享资源列表更新当前用户的共享数据表。Step 407: update the shared data table of the current user according to the second sharable resource list of at least one associated user.
在本实施例中,除了可根据当前用户的第一可共享资源列表更新关联用户的共享数据表以外,也可以根据至少一个关联用户的第二可共享资源列表更新当前用户的共享数据表。例如,假设用户A分别与用户B以及用户C的好友关系等级均升级至5级,用户A为当前用户,则用户B以及用户C均为用户A的关联用户,用户A当前的共享数据表中每种资源ID与对应的引用计数的关系如 下表3所示:
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 at least one associated user. For example, assuming that the friendship level of user A with user B and user C is upgraded to level 5, user A is the current user, and user B and user 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 as follows: As shown in Table 3 below:
表3table 3
假设用户B的第二可共享资源列表为{item_id1,item_id7},则根据用户B的第二可共享资源列表对用户A的如表3所示的共享数据表进行更新,对item_id1的引用计数自增1,以及,对item_id7的引用计数自增1,得到表4的共享数据表:
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 3 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 shared data table of Table 4 is obtained:
表4Table 4
假设用户C的第二可共享资源列表为{item_id2,item_id3},则根据用户C的第二可共享资源列表对用户A的如表4所示的共享数据表进行更新,对item_id2的引用计数自增1,以及,新增item_id3的记录并将item_id3的引用计数设置为1,得到表5的共享数据表:
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 4 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 the reference count of item_id3 is set to 1, so as to obtain the shared data table of Table 5:
表5table 5
当关联用户超过一个,当采用每个关联用户的第二可共享资源列表更新当 前用户的共享数据表,为了避免写入数据出错,可以采用线程锁对当前用户的共享数据表进行加锁处理。When there is more than one associated user, the second sharable resource list of each associated user is updated. To avoid errors in writing data to the shared data table of the previous user, you can use a thread lock to lock the shared data table of the current user.
在本实施例中,通过共享数据表来实现两用户间进行资源相互共享的资源管理,简化了资源相互共享的管理流程,提升了资源共享的管理效率。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.
实施例五Embodiment 5
图6为本申请实施例五提供的一种资源共享的方法的流程图,本实施例在上述任一实施例的基础上,对新增共享资源的过程进行说明,如图6所示,本实施例可以包括如下步骤。FIG6 is a flowchart of a resource sharing method provided in Embodiment 5 of the present application. Based on any of the above embodiments, this embodiment describes the process of adding new shared resources. As shown in FIG6 , this embodiment may include the following steps.
步骤501,当检测到用户的共享等级达标时,获取该用户的第一可共享资源列表。Step 501: when it is detected that the sharing level of a user reaches the standard, a first sharable resource list of the user is obtained.
步骤502,确定该用户的关联用户列表。Step 502: Determine a list of associated users of the user.
步骤503,获取关联用户列表中至少一个关联用户的共享数据表。Step 503: Obtain a shared data table of at least one associated user in the associated user list.
其中,该共享数据表为基于Redis存储结构的数据表,共享数据表携带用户标识,共享数据表中可以包括共享资源标识以及对应的引用计数,该引用计数用于记录对该用户标识分享当前共享资源标识对应的共享资源的用户的数量。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.
步骤504,根据第一可共享资源列表中的至少一种可共享资源更新至少一个关联用户的共享数据表。Step 504: update a shared data table of at least one associated user according to at least one sharable resource in the first sharable resource list.
步骤505,当当前用户获得新共享资源时,将该新共享资源写入当前用户的资源数据表中。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.
其中,该资源数据表为用于记录用户自有的资源的数据表,每种自有的资源可以以资源标识的形式记录在资源数据表中。The resource data table is a data table used to record user-owned resources, and each user-owned resource can be recorded in the resource data table in the form of a resource identifier.
该资源数据表可以存储在数据库中,如mysql数据库。The resource data table can be stored in a database, such as a MySQL database.
步骤506,根据该新共享资源更新至少一个关联用户的共享数据表。Step 506: Update the shared data table of at least one associated user according to the new shared resource.
其中,更新至少一个关联用户的共享数据表的方法可以参考上述实施例中步骤104的描述,即,遍历每个关联用户的共享数据表,如果该新共享资源存在于关联用户的共享数据表中,则将该新共享资源的资源标识对应的引用计数自增1;如果该新共享资源不存在于关联用户的共享数据表中,则将该新共享资源的资源标识添加到该共享数据表中并将该资源标识对应的引用计数设定为1。Among them, the method for updating the shared data table of at least one associated user can refer to the description of step 104 in the above embodiment, 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 reference count corresponding to the resource identifier is set to 1.
在本实施例中,当用户新增共享资源时,通过Redis操作直接根据新增的共享资源更新至少一个关联用户的共享数据表,而无需将新增的共享资源写入至 少一个关联用户的资源数据表中,避免出现写扩散问题,简化了新增共享资源的处理流程,提升了共享资源的维护效率,从而更好地提升了服务性能。In this embodiment, when a user adds a new shared resource, the shared data table of at least one associated user is updated directly according to the newly added shared resource through Redis operation, without writing the newly added shared resource to One less resource data table associated with a user avoids the problem of write diffusion, simplifies the processing flow of newly added shared resources, improves the maintenance efficiency of shared resources, and thus better improves service performance.
实施例六Embodiment 6
图7为本申请实施例六提供的一种资源共享的方法的流程图,本实施例在上述任一实施例的基础上,对共享资源的回收过程进行说明,如图7所示,本实施例可以包括如下步骤。FIG7 is a flowchart of a resource sharing method provided in Embodiment 6 of the present application. Based on any of the above embodiments, this embodiment describes the process of recycling shared resources. As shown in FIG7 , this embodiment may include the following steps.
步骤601,当检测到用户的共享等级达标时,获取该用户的第一可共享资源列表。Step 601: 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.
步骤602,确定该用户的关联用户列表。Step 602: Determine a list of associated users of the user.
步骤603,获取关联用户列表中至少一个关联用户的共享数据表。Step 603: Obtain a shared data table of at least one associated user in the associated user list.
其中,该共享数据表为基于Redis存储结构的数据表,共享数据表携带用户标识,共享数据表中可以包括共享资源标识以及对应的引用计数,该引用计数用于记录对该用户标识分享当前共享资源标识对应的共享资源的用户的数量。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.
步骤604,根据第一可共享资源列表中的至少一种可共享资源更新至少一个关联用户的共享数据表。Step 604: update a shared data table of at least one associated user according to at least one sharable resource in the first sharable resource list.
步骤605,当当前用户的可共享资源中出现失效资源时,基于该失效资源的资源标识在至少一个关联用户的共享数据表中进行查找,并对查找到的引用计数减1。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 at least one associated user based on the resource identifier of the invalid resource, and the reference count found is reduced by 1.
其中,失效资源指的是无法进行共享的资源。如果该资源已经共享出去,则需要进行资源回收。本实施例在进行资源回收时,直接对共享数据表中的引用计数进行更新,示例性的,可以在至少一个关联用户的共享数据表中查找该失效资源的资源标识,并将查找到的数据记录中的引用计数减1。The invalid resource refers to a resource that cannot be shared. If the resource has been shared, it is necessary to recycle the resource. In this embodiment, when recycling resources, the reference count in the shared data table is directly updated. For example, the resource identifier of the invalid resource can be searched in the shared data table of at least one associated user, and the reference count in the found data record is reduced by 1.
例如,在图2中,如果失效资源为item_id1,则可以将item_id1所在的数据记录中的引用计数由3更新为2。For example, in FIG2 , if the invalid resource is item_id1, the reference count in the data record where item_id1 is located may be updated from 3 to 2.
在一种实施例中,可以采用如下方式检测失效资源:当当前用户的共享等级降低至设定等级阈值时,则将该用户的每种可共享资源作为失效资源。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.
例如,如果要求用户的共享等级为游戏级别是7级时才达标,如果该用户的游戏级别降低到6级,低于达标的7级,则表示该用户没有共享资源的权限,此时可以将该用户的所有可共享资源均作为失效资源,并逐一采用每个失效资源对至少一个关联用户的共享数据表进行更新。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 each invalid resource can be used one by one to update the shared data table of at least one associated user.
在另一种实施例中,可以采用如下方式检测失效资源:当用户与其中的一 个或多个关联用户的关系等级低于设定关系等级阈值时,则将该用户的每种可共享资源作为失效资源。In another embodiment, the following method can be used to detect failed resources: when a user When the relationship level of one or more associated users is lower than the set relationship level threshold, each sharable resource of the user is regarded as an invalid resource.
例如,设定好友等级为5级,假设用户A与用户B的好友关系等级降低至4级,则两者之间的好友关系是不达标的,因此,可以将用户A的所有可共享资源均作为失效资源,并逐一采用每种失效资源对用户B的共享数据表进行更新。类似地,还可以将用户B的所有可共享资源均作为失效资源,并逐一采用每种失效资源对用户A的共享数据表进行更新。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 regarded as invalid resources, and each invalid resource is used to update the shared data table of user B one by one. Similarly, all sharable resources of user B can be regarded as invalid resources, and each invalid resource is used to update the shared data table of user A one by one.
在又一种实施例中,可以采用如下方式检测失效资源:当用户的第一可共享资源列表中存在过期的可共享资源,则将该过期的可共享资源作为失效资源。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.
其中,每个可共享资源都具有使用期限,如果超过该使用期限则对应的共享资源过期。示例性的,对于每个可共享资源,服务器还可以维护可共享资源信息表,如下表6所示,可共享资源信息表中可以包括拥有该可共享资源的用户标识(uid)、资源标识、资源有效期开始时间、资源有效期截止时间以及资源获得时间等字段,如果当前用户(uid为当前用户的uid)的可共享资源的资源有效期截止时间到达,则表示该可共享资源过期。
Each sharable resource has a usage period, and if the usage period is exceeded, the corresponding shared resource expires. Exemplarily, 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.
表6Table 6
本实施例可以将过期的可共享资源作为失效资源,并采用该失效资源对至少一个关联用户的共享数据表进行更新。In this embodiment, expired sharable resources may be used as invalid resources, and the shared data table of at least one associated user may be updated using the invalid resources.
步骤606,当共享数据表中出现数值为0的引用计数时,则在共享数据表中将数值为0的引用计数对应的资源记录删除。Step 606: When a reference count with a value of 0 appears in the shared data table, the resource record corresponding to the reference count with a value of 0 is deleted from the shared data table.
在进行引用计数的自减操作以后,如果一个共享数据表中出现数值为0的引用计数,则在该共享数据表中将该数值为0的引用计数所在的资源记录删除。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.
在本实施例中,在进行共享资源回收时,只需要对共享数据表中的引用计数进行操作即可,无需对数据库进行操作,极大地简化了资源回收的过程,提 升共享资源的管理效率。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 efficiency of resource recycling. Improve the management efficiency of shared resources.
实施例七Embodiment 7
图8为本申请实施例七提供的一种数据查询的方法的流程图,与前述实施例相比,本实施例侧重于读取数据的场景,而前述实施例侧重于写入数据的场景,如图8所示,本实施例可以包括如下步骤。FIG8 is a flowchart of a method for data query provided in Embodiment 7 of the present application. Compared with the aforementioned embodiments, this embodiment focuses on the scenario of reading data, while the aforementioned embodiments focus on the scenario of writing data. As shown in FIG8 , this embodiment may include the following steps.
步骤701,响应于用户的资源查询请求,读取该用户的资源数据表中的资源数据,并将读取到的资源数据表中的资源数据作为第一资源数据。Step 701: In response to a resource query request from a user, resource data in a resource data table of the user is read, and the resource data in the resource data table read is used as first resource data.
当用户需要查询自己的可用资源时,可以在客户端页面发起资源查询请求,该资源查询请求携带该用户的用户标识。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.
获得当前用户的用户标识以后,可以根据该用户标识在数据库中查找到该用户标识对应的资源数据表,并读取该资源数据表中的资源数据,将读取的资源数据作为第一资源数据。其中,该资源数据表为用于记录用户自有的资源的数据表,每个自有的资源可以以资源标识的形式记录在资源数据表中。该第一资源数据可以包括当前用户自有的资源的资源标识。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, and the read resource data can be used as the first resource data. The resource data table is a data table for recording the user's own resources, and each owned resource can be recorded in the resource data table in the form of a resource ID. The first resource data can include the resource ID of the current user's own resources.
步骤702,读取该用户的共享数据表中的资源数据,并将读取到的共享数据表中的资源数据作为第二资源数据。Step 702: read the resource data in the shared data table of the user, and use the resource data in the shared data table read as the second resource data.
其中,该共享数据表为基于Redis存储结构的数据表,该共享数据表携带用户标识,该共享数据表中包括共享资源标识以及共享资源标识对应的引用计数,引用计数用于记录对该用户标识分享所述共享资源标识对应的共享资源的用户的数量。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 reference count corresponding to the shared resource identifier. 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.
获得当前用户的用户标识以后,还可以根据该用户标识在Redis中查找该用户标识对应的共享数据表,读取该共享数据表中的资源数据,将读取的资源数据作为第二资源数据。该第二资源数据可以包括当前用户被共享的资源的资源标识以及每个资源标识对应的引用计数。After obtaining the user ID of the current user, the shared data table corresponding to the user ID can also be searched in Redis according to the user ID, and the resource data in the shared data table can be read, and the read resource data can be used as the second resource data. The second resource data can include the resource ID of the resource shared by the current user and the reference count corresponding to each resource ID.
步骤703,基于所述第一资源数据以及所述第二资源数据生成资源展示列表,并返回所述资源展示列表。Step 703: Generate a resource display list based on the first resource data and the second resource data, and return the resource display list.
在实现时,通过对第一资源数据以及第二资源数据进行融合生成资源展示列表。其中一种融合的实现方案为:将第一资源数据和第二资源数据写入预先配置的展示模板中,生成资源展示列表。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.
在资源展示列表中可以包括第一资源数据中的每个资源标识及每个资源标识对应的引用计数以及第二资源数据中的每个资源标识及每个资源标识对应的 引用计数。如果资源标识为代码类型,则可以将该资源标识转换成资源名称后再展示,如图9所示,其中,在图9中,自有资源来源于第一资源数据,被共享资源来源于第二资源数据。The resource display list may include each resource identifier in the first resource data and the reference count corresponding to each resource identifier, and each resource identifier in the second resource data and the reference count corresponding to each resource identifier. Reference count: If the resource identifier is a code type, the resource identifier can be converted into a resource name and then displayed, as shown in FIG9 , where the owned resource is derived from the first resource data and the shared resource is derived from the second resource data.
在本实施例中,在进行资源查询时,进行一次数据库查询(在资源数据表中进行查询)和一次Redis查询(在共享数据表中查询)即可,无需分别对至少一个关联用户的资源数据表进行查询,I/O操作次数减少,避免读扩散问题,有效地减少了数据库操作的次数,从而降低数据库负载,提升服务响应效率。In this embodiment, when performing a resource query, it is sufficient to perform one database query (query in the resource data table) and one Redis query (query in the shared data table). There is no need to query the resource data table of at least one associated user separately. The number of I/O 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.
同时,由于Redis操作性能比数据库操作要高出几个数量级,因此本实施例在高并发场景下能极大的提升服务性能,减轻数据库压力。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.
实施例八Embodiment 8
图10为本申请实施例八提供的一种资源共享的装置的结构示意图,可以包括如下模块。FIG10 is a schematic diagram of the structure of a resource sharing device provided in Embodiment 8 of the present application, which may include the following modules.
第一可共享资源列表获取模块801,设置为当检测到用户的共享等级达标时,获取所述用户的第一可共享资源列表;A first sharable resource list acquisition module 801, 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;
关联用户列表确定模块802,设置为确定所述用户的关联用户列表;An associated user list determination module 802 is configured to determine an associated user list of the user;
第一共享数据表获取模块803,设置为获取所述关联用户列表中至少一个关联用户的共享数据表,其中,所述共享数据表为基于Redis存储结构的数据表,所述共享数据表携带用户标识,所述共享数据表中包括共享资源标识以及共享资源标识对应的引用计数,所述引用计数用于记录对该用户标识分享所述共享资源标识对应的共享资源的用户的数量;A first shared data table acquisition module 803 is configured to acquire a shared data table of at least one 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 reference count corresponding to the shared resource identifier, 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;
第一共享数据表更新模块804,设置为根据所述第一可共享资源列表中的至少一种可共享资源更新至少一个关联用户的共享数据表。The first shared data table updating module 804 is configured to update the shared data table of at least one associated user according to at least one sharable resource in the first sharable resource list.
在一种实施例中,第一共享数据表更新模块804是设置为:In one embodiment, the first shared data table updating module 804 is configured to:
获取每种可共享资源的资源标识;Get the resource identifier of each shareable resource;
在每个共享数据表中匹配所述资源标识;Matching the resource identifier in each shared data table;
若匹配成功,则将匹配上的共享资源标识对应的引用计数加1;If the match is successful, the reference count corresponding to the matched shared resource identifier is increased by 1;
若匹配失败,则在所述共享数据表中新增所述资源标识作为共享资源标识,并标记该资源标识的引用计数为1。If the match fails, the resource identifier is added to the shared data table as a shared resource identifier, and the reference count of the resource identifier is marked as 1.
在一种实施例中,所述装置还包括第一达标检测模块,设置为:In one embodiment, the device further includes a first compliance detection module configured to:
当所述用户与所述用户的关系列表中的其中一个或多个关系用户的关系等 级达到设定关系等级阈值,则判定所述用户的共享等级达标。When the relationship between the user and one or more of the relationship users in the relationship list of the user If the level reaches the set relationship level threshold, it is determined that the sharing level of the user meets the requirement.
在一种实施例中,关联用户列表确定模块802是设置为:In one embodiment, the associated user list determination module 802 is configured to:
将所述关系等级达到设定关系等级阈值的关系用户确定为关联用户,生成关联用户列表。The related users whose relationship levels reach the set relationship level threshold are determined as associated users, and an associated user list is generated.
在另一种实施例中,所述装置还包括第二达标检测模块,设置为:In another embodiment, the device further includes a second compliance detection module configured to:
当用户的共享等级达到设定等级阈值时,则判定所述用户的共享等级达标。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.
在另一种实施例中,关联用户列表确定模块802是设置为:In another embodiment, the associated user list determination module 802 is configured to:
将与所述用户存在指定关联关系的用户作为关联用户,生成关联用户列表。Users having a specified association relationship with the user are taken as associated users, and an associated user list is generated.
在一种实施例中,所述装置还可以包括:In one embodiment, the device may further include:
第二可共享资源列表获取模块,设置为获取至少一个关联用户的第二可共享资源列表;A second sharable resource list acquisition module, configured to acquire a second sharable resource list of at least one associated user;
第二共享数据表获取模块,设置为获取所述用户的共享数据表;A second shared data table acquisition module, configured to acquire the shared data table of the user;
第二共享数据表更新模块,设置为分别根据至少一个关联用户的第二可共享资源列表更新所述用户的共享数据表。The second shared data table updating module is configured to update the shared data table of the user according to the second sharable resource list of at least one associated user.
在一种实施例中,所述装置还可以包括:In one embodiment, the device may further include:
资源数据表写入模块,设置为当所述用户获得新共享资源时,将所述新共享资源写入所述用户的资源数据表中;A resource data table writing module, configured to write a new shared resource into the resource data table of the user when the user obtains the new shared resource;
新增资源写入模块,设置为根据所述新共享资源更新至少一个关联用户的共享数据表。The newly added resource writing module is configured to update the shared data table of at least one associated user according to the new shared resource.
在一种实施例中,所述装置还可以包括:In one embodiment, the device may further include:
资源回收模块,设置为当所述用户的可共享资源中出现失效资源时,基于所述失效资源的资源标识在至少一个关联用户的共享数据表中进行查找,并对查找到的引用计数减1;当所述共享数据表中出现数值为0的引用计数,则在所述共享数据表中将所述数值为0的引用计数对应的资源记录删除。The resource recovery module is configured to search in a shared data table of at least one 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 a reference count with a value of 0 appears in the shared data table, the resource record corresponding to the reference count with a value of 0 is deleted in the shared data table.
在一种实施例中,所述失效资源采用如下方式检测:In one embodiment, the failed resource is detected in the following manner:
当所述用户的共享等级降低至设定等级阈值时,则将所述用户的每种可共享资源作为失效资源;When the sharing level of the user is reduced to a set level threshold, each shareable resource of the user is regarded as an invalid resource;
或者,or,
当所述用户的第一可共享资源列表存在过期的可共享资源,则将该过期的可共享资源作为失效资源; When there is an expired sharable resource in the first sharable resource list of the user, the expired sharable resource is regarded as an invalid resource;
或者,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.
本申请实施例所提供的一种资源共享的装置可执行本申请任一实施例所提供的一种资源共享的方法,具备执行方法相应的功能模块和效果。A resource sharing device provided in an embodiment of the present application can execute a resource sharing method provided in any embodiment of the present application, and has functional modules and effects corresponding to the execution method.
实施例九Embodiment 9
图11为本申请实施例九提供的一种数据查询的装置的结构示意图,可以包括如下模块。FIG11 is a schematic diagram of the structure of a data query device provided in Embodiment 9 of the present application, which may include the following modules.
第一查询模块901,设置为响应于用户的资源查询请求,读取所述用户的资源数据表中的资源数据,并将读取到的资源数据表中的资源数据作为第一资源数据;The first query module 901 is configured to respond to a resource query request of a user, read resource data in a resource data table of the user, and use the resource data in the resource data table read as first resource data;
第二查询模块902,设置为读取所述用户的共享数据表中的资源数据,并将读取到的共享数据表中的资源数据作为第二资源数据,其中,所述共享数据表为基于Redis存储结构的数据表,所述共享数据表携带用户标识,所述共享数据表中包括共享资源标识以及共享资源标识对应的引用计数,所述引用计数用于记录对该用户标识分享所述共享资源标识对应的共享资源的用户的数量;The second query module 902 is configured to read the resource data in the shared data table of the user, and use the resource data in the shared data table read 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 reference count corresponding to the shared resource identifier, 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;
资源展示列表生成模块903,设置为基于所述第一资源数据以及所述第二资源数据生成资源展示列表,并返回所述资源展示列表。The resource display list generating module 903 is configured to generate a resource display list based on the first resource data and the second resource data, and return the resource display list.
本申请实施例所提供的一种数据查询的装置可执行本申请实施例所提供的一种数据查询的方法,具备执行方法相应的功能模块和效果。A data query device provided in an embodiment of the present application can execute a data query method provided in an embodiment of the present application, and has functional modules and effects corresponding to the execution method.
实施例十Embodiment 10
图12示出了可以用来实施本申请的方法实施例的服务器10的结构示意图。如图12所示,服务器10包括至少一个处理器11,以及与至少一个处理器11通信连接的存储装置,如只读存储器(Read-Only Memory,ROM)12、随机访问存储器(Random Access Memory,RAM)13等,其中,存储装置存储有可被至少一个处理器11执行的一个或多个计算机程序,处理器11可以根据存储在ROM12中的计算机程序或者从存储单元18加载到RAM13中的计算机程序,来执行多种适当的动作和处理。在RAM 13中,还可存储服务器10操作所需的多种程序和数据。FIG12 shows a schematic diagram of the structure of a server 10 that can be used to implement the method embodiment of the present application. As shown in FIG12, the server 10 includes at least one processor 11, and a storage device that is connected to the at least one processor 11 in communication, 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 11, and the processor 11 can perform a variety of appropriate actions and processes according to the computer program stored in the ROM 12 or the computer program loaded from the storage unit 18 to the RAM 13. In the RAM 13, a variety of programs and data required for the operation of the server 10 can also be stored.
在一些实施例中,本申请任一实施例中的方法可被实现为计算机程序, 其被有形地包含于计算机可读存储介质,例如存储单元18。存储介质可以是非暂态(non-transitory)存储介质。在一些实施例中,计算机程序的部分或者全部可以经由ROM 12和/或通信单元19而被载入和/或安装到服务器10上。当计算机程序加载到RAM 13并由处理器11执行时,可以执行上文描述的本申请任一实施例中的方法。In some embodiments, the method in any embodiment of the present application may be implemented as a computer program. It is tangibly contained in a computer-readable storage medium, such as a storage unit 18. The storage medium may be a non-transitory storage medium. 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, the method in any embodiment of the present application described above may be executed.
在一些实施例中,本申请任一实施例中的方法可被实现为计算机程序产品,该计算机程序产品包括计算机可执行指令,该计算机可执行指令在被执行时用于执行上文描述的本申请任一实施例中的方法。 In some embodiments, the method in any embodiment of the present application may be implemented as a computer program product, which includes computer executable instructions, which are used to execute the method in any embodiment of the present application described above when executed.

Claims (14)

  1. 一种资源共享的方法,包括:A resource sharing method, comprising:
    在检测到用户的共享等级达标的情况下,获取所述用户的第一可共享资源列表;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;
    获取所述关联用户列表中至少一个关联用户的共享数据表,其中,所述共享数据表为基于远程字典服务Redis存储结构的数据表,所述共享数据表携带用户标识,所述共享数据表中包括共享资源标识以及所述共享资源标识对应的引用计数,所述引用计数用于记录对所述用户标识分享所述共享资源标识对应的共享资源的用户的数量;Obtaining a shared data table of at least one associated user in the associated user list, wherein the shared data table is a data table based on a remote dictionary service Redis storage structure, the shared data table carries a user identifier, and the shared data table includes a shared resource identifier and a reference count corresponding to the shared resource identifier, 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;
    根据所述第一可共享资源列表中的至少一种可共享资源更新所述至少一个关联用户的共享数据表。The shared data table of the at least one associated user is updated according to at least one sharable resource in the first sharable resource list.
  2. 根据权利要求1所述的方法,其中,所述根据所述第一可共享资源列表中的至少一种可共享资源更新所述至少一个关联用户的共享数据表,包括:The method according to claim 1, wherein the updating of the shared data table of the at least one associated user according to the at least one sharable resource in the first sharable resource list comprises:
    获取每种可共享资源的资源标识;Get the resource identifier of each shareable resource;
    在每个共享数据表中匹配所述资源标识;Matching the resource identifier in each shared data table;
    在匹配成功的情况下,将匹配上的共享资源标识对应的引用计数加1;If the match is successful, the reference count corresponding to the matched shared resource identifier is increased by 1;
    在匹配失败的情况下,在所述共享数据表中新增所述资源标识作为共享资源标识,并标记所述资源标识的引用计数为1。In the case of a matching failure, the resource identifier is added to the shared data table as a shared resource identifier, and the reference count of the resource identifier is marked as 1.
  3. 根据权利要求1或2所述的方法,其中,采用如下方式检测所述用户的共享等级是否达标:The method according to claim 1 or 2, wherein the following method is used to detect whether the sharing level of the user meets the standard:
    在所述用户与所述用户的关系列表中的其中一个或多个关系用户的关系等级达到设定关系等级阈值的情况下,判定所述用户的共享等级达标。When the relationship level between the user and one or more related users in the relationship list of the user reaches a set relationship level threshold, it is determined that the sharing level of the user meets the requirement.
  4. 根据权利要求3所述的方法,其中,所述确定所述用户的关联用户列表,包括:The method according to claim 3, wherein determining the list of associated users of the user comprises:
    将所述关系等级达到所述设定关系等级阈值的关系用户确定为关联用户,生成所述关联用户列表。The related users whose relationship levels reach the set relationship level threshold are determined as associated users, and the associated user list is generated.
  5. 根据权利要求1所述的方法,其中,在所述根据所述第一可共享资源列表中的至少一种可共享资源更新所述至少一个关联用户的共享数据表之后,所述方法还包括:The method according to claim 1, wherein after updating the shared data table of the at least one associated user according to the at least one sharable resource in the first sharable resource list, the method further comprises:
    获取所述至少一个关联用户的第二可共享资源列表;Acquire a second sharable resource list of the at least one 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 the at least one associated user.
  6. 根据权利要求1或2或5所述的方法,还包括:The method according to claim 1, 2 or 5, further comprising:
    在所述用户获得新共享资源的情况下,将所述新共享资源写入所述用户的资源数据表中;When the user obtains a new shared resource, writing the new shared resource into the resource data table of the user;
    根据所述新共享资源更新所述至少一个关联用户的共享数据表。The shared data table of the at least one associated user is updated according to the new shared resource.
  7. 根据权利要求1或2或5所述的方法,还包括:The method according to claim 1, 2 or 5, further comprising:
    在所述用户的可共享资源中出现失效资源的情况下,基于所述失效资源的资源标识在所述至少一个关联用户的共享数据表中进行查找,并对查找到的引用计数减1;In the case where an invalid resource appears in the sharable resources of the user, searching in the shared data table of the at least one associated user based on the resource identifier of the invalid resource, and reducing the reference count found by 1;
    在所述共享数据表中出现数值为0的引用计数的情况下,在所述共享数据表中将所述数值为0的引用计数对应的资源记录删除。When a reference count with a value of 0 appears in the shared data table, a resource record corresponding to the reference count with a value of 0 is deleted from the shared data table.
  8. 根据权利要求7所述的方法,其中,所述失效资源采用如下方式检测:The method according to claim 7, wherein 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 the invalid resource;
    或者,or,
    在所述用户的第一可共享资源列表存在过期的可共享资源的情况下,将所述过期的可共享资源作为所述失效资源;In the case where there are expired sharable resources in the first sharable resource list of the user, taking the expired sharable resources as the invalid resources;
    或者,or,
    在所述用户与其中的一个或多个关联用户的关系等级低于设定关系等级阈值的情况下,将所述用户的每种可共享资源作为所述失效资源。In the case that 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 used as the invalid resource.
  9. 一种数据查询的方法,包括:A data query method, comprising:
    响应于用户的资源查询请求,读取所述用户的资源数据表中的资源数据,并将读取到的资源数据表中的资源数据作为第一资源数据;In response to a resource query request from a user, resource data in a resource data table of the user is read, and the resource data in the resource data table read is used as first resource data;
    读取所述用户的共享数据表中的资源数据,并将读取到的共享数据表中的资源数据作为第二资源数据,其中,所述共享数据表为基于远程字典服务Redis存储结构的数据表,所述共享数据表携带用户标识,所述共享数据表中包括共享资源标识以及所述共享资源标识对应的引用计数,所述引用计数用于记录对所述用户标识分享所述共享资源标识对应的共享资源的用户的数量;Read resource data in a shared data table of the user, and use the resource data in the shared data table read as second resource data, wherein the shared data table is a data table based on a remote dictionary service Redis storage structure, the shared data table carries a user identifier, and the shared data table includes a shared resource identifier and a reference count corresponding to the shared resource identifier, 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;
    基于所述第一资源数据以及所述第二资源数据生成资源展示列表,并返回所述资源展示列表。 A resource display list is generated based on the first resource data and the second resource data, and the resource display list is returned.
  10. 一种资源共享的装置,包括:A resource sharing device, comprising:
    第一可共享资源列表获取模块,设置为在检测到用户的共享等级达标的情况下,获取所述用户的第一可共享资源列表;A first sharable resource list acquisition module, configured to acquire a first sharable resource list of the user when detecting that the user's sharing level meets the requirement;
    关联用户列表确定模块,设置为确定所述用户的关联用户列表;An associated user list determination module, configured to determine an associated user list of the user;
    第一共享数据表获取模块,设置为获取所述关联用户列表中至少一个关联用户的共享数据表,其中,所述共享数据表为基于远程字典服务Redis存储结构的数据表,所述共享数据表携带用户标识,所述共享数据表中包括共享资源标识以及所述共享资源标识对应的引用计数,所述引用计数用于记录对所述用户标识分享所述共享资源标识对应的共享资源的用户的数量;a first shared data table acquisition module, configured to acquire a shared data table of at least one associated user in the associated user list, wherein the shared data table is a data table based on a remote dictionary service Redis storage structure, the shared data table carries a user identifier, the shared data table includes a shared resource identifier and a reference count corresponding to the shared resource identifier, 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 first shared data table updating module is configured to update the shared data table of the at least one associated user according to at least one sharable resource in the first sharable resource list.
  11. 一种数据查询的装置,包括:A data query device, comprising:
    第一查询模块,设置为响应于用户的资源查询请求,读取所述用户的资源数据表中的资源数据,并将读取到的资源数据表中的资源数据作为第一资源数据;A first query module is configured to respond to a resource query request of a user, read resource data in a resource data table of the user, and use the resource data in the resource data table read as first resource data;
    第二查询模块,设置为读取所述用户的共享数据表中的资源数据,并将读取到的共享数据表中的资源数据作为第二资源数据,其中,所述共享数据表为基于远程字典服务Redis存储结构的数据表,所述共享数据表携带用户标识,所述共享数据表中包括共享资源标识以及所述共享资源标识对应的引用计数,所述引用计数用于记录对所述用户标识分享所述共享资源标识对应的共享资源的用户的数量;a second query module, configured to read resource data in a shared data table of the user, and use the resource data in the shared data table read as second resource data, wherein the shared data table is a data table based on a remote dictionary service Redis storage structure, the shared data table carries a user identifier, the shared data table includes a shared resource identifier and a reference count corresponding to the shared resource identifier, 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 configured to generate a resource display list based on the first resource data and the second resource data, and return the resource display list.
  12. 一种服务器,包括:A server, comprising:
    一个或多个处理器;one or more processors;
    存储装置,设置为存储一个或多个程序,a storage device configured to store one or more programs,
    当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如权利要求1至9中任一项所述的方法。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 9.
  13. 一种计算机可读存储介质,其上存储有计算机程序,其中,所述计算机程序被处理器执行时实现如权利要求1至9中任一项所述的方法。A computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.
  14. 一种计算机程序产品,所述计算机程序产品包括计算机可执行指令,所述计算机可执行指令在被执行时用于实现权利要求1至9中任一项所述的方 法。 A computer program product, comprising computer executable instructions, which are used to implement any one of claims 1 to 9 when executed. Law.
PCT/CN2023/125200 2022-11-02 2023-10-18 Resource sharing method and apparatus, data query method and apparatus, and server WO2024093675A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211363501.7 2022-11-02
CN202211363501.7A CN115914387A (en) 2022-11-02 2022-11-02 Resource sharing and data query method, device and server

Publications (1)

Publication Number Publication Date
WO2024093675A1 true WO2024093675A1 (en) 2024-05-10

Family

ID=86492516

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/125200 WO2024093675A1 (en) 2022-11-02 2023-10-18 Resource sharing method and apparatus, data query method and apparatus, and server

Country Status (2)

Country Link
CN (1) CN115914387A (en)
WO (1) WO2024093675A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115914387A (en) * 2022-11-02 2023-04-04 百果园技术(新加坡)有限公司 Resource sharing and data query method, device and server

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120054280A1 (en) * 2010-08-25 2012-03-01 International Business Machines Corporation Sharing Cloud Data Resources With Social Network Associates
US10623929B1 (en) * 2016-08-11 2020-04-14 Mahesh Harpale Method and apparatus for shared mobile device app with unique business function adaptation and rendering
CN114082196A (en) * 2021-11-30 2022-02-25 完美世界(北京)软件科技发展有限公司 Game resource control method and device, storage medium and electronic device
CN114443868A (en) * 2020-10-30 2022-05-06 腾讯科技(深圳)有限公司 Multimedia list generation method and device, storage medium and electronic equipment
CN115914387A (en) * 2022-11-02 2023-04-04 百果园技术(新加坡)有限公司 Resource sharing and data query method, device and server

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104199800A (en) * 2014-07-21 2014-12-10 上海寰创通信科技股份有限公司 Method for eliminating mutual exclusion of table items in multi-core system
CN104125297A (en) * 2014-08-06 2014-10-29 华为技术有限公司 Virtual resource sharing method, device and system
CN106790597A (en) * 2016-12-29 2017-05-31 江西博瑞彤芸科技有限公司 The acquisition methods of users to share view data
US10637919B2 (en) * 2017-03-23 2020-04-28 Microsoft Technology Licensing, Llc Autonomous resource governor in distributed systems for protecting shared resources
US11137924B2 (en) * 2017-08-25 2021-10-05 Vmware, Inc. Distributed file storage system supporting accesses from multiple container hosts
CN108804174A (en) * 2018-05-04 2018-11-13 努比亚技术有限公司 A kind of game control method, server, terminal and computer readable storage medium
KR102423690B1 (en) * 2020-01-08 2022-07-21 라인플러스 주식회사 Method and system for sharing avatars through instant messaging application
CN111460049A (en) * 2020-04-01 2020-07-28 北京字节跳动网络技术有限公司 Content sharing method and device, electronic equipment and computer readable storage medium
CN112604270A (en) * 2020-12-29 2021-04-06 北京冰封互娱科技有限公司 Cross-server method, device and equipment for online game
CN114694816A (en) * 2022-04-24 2022-07-01 康键信息技术(深圳)有限公司 Resource sharing processing method, device, equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120054280A1 (en) * 2010-08-25 2012-03-01 International Business Machines Corporation Sharing Cloud Data Resources With Social Network Associates
US10623929B1 (en) * 2016-08-11 2020-04-14 Mahesh Harpale Method and apparatus for shared mobile device app with unique business function adaptation and rendering
CN114443868A (en) * 2020-10-30 2022-05-06 腾讯科技(深圳)有限公司 Multimedia list generation method and device, storage medium and electronic equipment
CN114082196A (en) * 2021-11-30 2022-02-25 完美世界(北京)软件科技发展有限公司 Game resource control method and device, storage medium and electronic device
CN115914387A (en) * 2022-11-02 2023-04-04 百果园技术(新加坡)有限公司 Resource sharing and data query method, device and server

Also Published As

Publication number Publication date
CN115914387A (en) 2023-04-04

Similar Documents

Publication Publication Date Title
US11860874B2 (en) Multi-partitioning data for combination operations
US11151137B2 (en) Multi-partition operation in combination operations
EP2047382B1 (en) Two-way and multi-master synchronization over web syndications
US8838679B2 (en) Providing state service for online application users
US20150169741A1 (en) Methods And Systems For Eliminating Duplicate Events
WO2024093675A1 (en) Resource sharing method and apparatus, data query method and apparatus, and server
US20120203797A1 (en) Enhanced control to users to populate a cache in a database system
JP2002099454A (en) File control system and method
US10055475B2 (en) Authentication system, synchronization method, and authentication apparatus
US20130066869A1 (en) Computer system, method of managing a client computer, and storage medium
JP2008181350A (en) Information processing system, information processor and program
WO2019161620A1 (en) Application dependency update method, terminal and device, and storage medium
JP6111186B2 (en) Distributed information linkage system and data operation method and program thereof
JP5442726B2 (en) Method for performing a distributed search
CN109614411B (en) Data storage method, device and storage medium
CN112559913B (en) Data processing method, device, computing equipment and readable storage medium
JP2002049637A (en) Database management method, device and recording medium
US7441252B2 (en) Cache control device, and method and computer program for the same
JPH11312154A (en) Cooperative work aiding system and recording medium thereof
US7433875B2 (en) Web store events
US20210232603A1 (en) Capturing data lake changes
US20210173729A1 (en) Systems and methods of application program interface (api) parameter monitoring
CN114116732B (en) Transaction processing method and device, storage device and server
JP2004013694A (en) Information processing system with front end processing function
CN111598560A (en) Data modification method and device based on storage service and storage server

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23884607

Country of ref document: EP

Kind code of ref document: A1