A method, device, equipment and storage medium for storing authority data
By calculating the identification information of the object to determine the storage address of the permission data and directly retrieving the permission data, the problem of low retrieval efficiency in the existing technology is solved and a faster retrieval process is achieved.
Patent Information
- Application Number
- CN202311800893.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-25
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2043-12-25
AI Technical Summary
When retrieving the permission data of a specific object, the existing technology needs to traverse the entire relational database, resulting in poor retrieval efficiency and long time consumption.
By obtaining the identification information of the object, the corresponding storage address is calculated, and the permission data is stored in a specific array. During subsequent retrieval, the storage address is directly calculated based on the identification information to avoid traversing the entire database.
Retrieval time is shortened, retrieval efficiency is improved, and retrieval volume is reduced.
Smart Images

Figure CN117610059B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data storage, and in particular to a method, device, equipment and storage medium for storing permission data. Background Art
[0002] Permission data refers to the data on access or operation permissions related to a specific object (such as a user). Permission data is used to manage the access rights of a specific object to a system, application, or resource, thereby ensuring that a specific object can only perform tasks within its scope of permission.
[0003] Currently, permission data can be stored in a relational database (such as MySQL). However, in the process of retrieving permission data corresponding to a specific object, the entire relational database needs to be traversed, which is time-consuming and has poor retrieval efficiency. Summary of the invention
[0004] The present application provides a method, apparatus, device and storage medium for storing permission data, which can improve the efficiency of retrieving permission data and shorten the retrieval time.
[0005] In order to achieve the above objectives, this application adopts the following technical solutions:
[0006] In a first aspect, the present application provides a method for storing permission data, the method comprising:
[0007] Acquire first permission data of a first object, where the first permission data includes first identification information and permission information of the first object, where the first identification information is used to uniquely identify the first object;
[0008] Calculating a first storage address corresponding to the first permission data according to the first identification information;
[0009] The first authority data is stored according to the first storage address.
[0010] In some possible implementations, calculating, according to the first identification information, a first storage address corresponding to the first permission data includes:
[0011] Calculate, according to the first identification information, a first storage sub-address of the first identification information in the first array and a second storage sub-address of the first permission information in the second array;
[0012] The storing the first permission data according to the first storage address includes:
[0013] The first identification information is stored in the first array according to the first storage sub-address, and the first permission information is stored in the second array according to the second storage sub-address.
[0014] In some possible implementations, calculating, according to the first identification information, a first storage sub-address of the first identification information in the first array and a second storage sub-address of the first permission information in the second array includes:
[0015] The first identification information is used to perform a modulo operation on a preset reference value to obtain a modulo result, where the modulo result is a first storage sub-address of the first identification information in the first array and a second storage sub-address of the first permission information in the second array.
[0016] In some possible implementations, calculating, according to the first identification information, a first storage sub-address of the first identification information in the first array and a second storage sub-address of the first permission information in the second array includes:
[0017] A first storage sub-address of the first identification information and a second storage sub-address of the first permission information are calculated according to the first identification information and the length of a first array, wherein the first array has the same length as the second array.
[0018] In some possible implementations, the method further includes:
[0019] receiving a search request, wherein the search request carries second identification information of a second object;
[0020] Calculating, according to the second identification information, a second storage address corresponding to the second permission data of the second object;
[0021] The second permission data of the second object is retrieved from the second storage address.
[0022] In some possible implementations, the method further includes:
[0023] Obtaining a first creation time of the first object;
[0024] Determining a first storage area for the first permission data according to the first creation time;
[0025] The calculating, according to the first identification information, a first storage address corresponding to the first permission data includes:
[0026] A first storage address corresponding to the first permission data in the first storage area is calculated according to the first identification information.
[0027] In some possible implementations, the method further includes:
[0028] Randomly extracting n-bit elements from the first identification information;
[0029] Determining a first storage area for the first permission data according to the randomly selected n-bit element;
[0030] The calculating, according to the first identification information, a first storage address corresponding to the first permission data includes:
[0031] A first storage address corresponding to the first permission data in the first storage area is calculated according to the first identification information.
[0032] In a second aspect, the present application provides a storage device for permission data, the device comprising:
[0033] An acquisition module, configured to acquire first permission data of a first object, wherein the first permission data includes first identification information and permission information of the first object, and the first identification information is used to uniquely identify the first object;
[0034] a calculation module, configured to calculate a first storage address corresponding to the first permission data according to the first identification information;
[0035] A storage module is used to store the first permission data according to the first storage address.
[0036] In some possible implementations, the calculation module is specifically used to calculate a first storage sub-address of the first identification information in the first array and a second storage sub-address of the first permission information in the second array based on the first identification information; the storage module is specifically used to store the first identification information in the first array based on the first storage sub-address, and store the first permission information in the second array based on the second storage sub-address.
[0037] In some possible implementations, the calculation module is specifically used to use the first identification information to perform a modulo operation on a preset reference value to obtain a modulo result, wherein the modulo result is the first storage sub-address of the first identification information in the first array and the second storage sub-address of the first permission information in the second array.
[0038] In some possible implementations, the calculation module is specifically used to calculate the first storage sub-address of the first identification information and the second storage sub-address of the first permission information based on the first identification information and the length of the first array, and the length of the first array is the same as that of the second array.
[0039] In some possible implementations, the device further includes: a receiving module and a retrieving module;
[0040] The receiving module is used to receive a retrieval request, which carries second identification information of a second object; the calculating module is also used to calculate a second storage address corresponding to second permission data of the second object based on the second identification information; and the retrieval module is used to retrieve the second permission data of the second object from the second storage address.
[0041] In some possible implementations, the device further includes a determination module;
[0042] The acquisition module is also used to obtain the first creation time of the first object; the determination module is used to determine the first storage area of the first permission data based on the first creation time; the calculation module is specifically used to calculate the first storage address corresponding to the first permission data in the first storage area based on the first identification information.
[0043] In some possible implementations, the apparatus further includes: a determination module;
[0044] The acquisition module is used to randomly extract an n-bit element from the first identification information; the determination module is used to determine a first storage area for the first permission data based on the randomly extracted n-bit element; the calculation module is specifically used to calculate a first storage address corresponding to the first permission data in the first storage area based on the first identification information.
[0045] In a third aspect, the present application provides an electronic device, including a memory and a processor;
[0046] Wherein, one or more computer programs are stored in the memory, and the one or more computer programs include instructions; when the instructions are executed by the processor, the electronic device executes the method as described in any one of the first aspects.
[0047] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method as described in any one of the first aspects.
[0048] It can be seen from the above technical solution that the present application has at least the following beneficial effects:
[0049] The present application provides a method for storing permission data, the method comprising obtaining first permission data of a first object, the first permission data comprising first identification information and first permission information of the first object, wherein the first identification information is used to uniquely identify the first object, and then based on the first identification information, a first storage address corresponding to the first permission data is calculated, and finally based on the first storage address, the first permission data is stored. After the permission data is stored by the above method, in the subsequent retrieval process of the permission data of the first object, the corresponding storage address can also be calculated based on the identification information, and then the permission data can be retrieved based on the calculated storage address. Compared with the retrieval method of traversing the database, the retrieval amount and retrieval time are reduced, and the retrieval efficiency is improved.
[0050] It should be understood that the description of technical features, technical solutions, beneficial effects or similar language in this application does not imply that all features and advantages can be realized in any single embodiment. On the contrary, it is understood that the description of features or beneficial effects means that specific technical features, technical solutions or beneficial effects are included in at least one embodiment. Therefore, the description of technical features, technical solutions or beneficial effects in this specification does not necessarily refer to the same embodiment. Furthermore, the technical features, technical solutions and beneficial effects described in the present embodiment can also be combined in any appropriate manner. Those skilled in the art will understand that the embodiment can be realized without one or more specific technical features, technical solutions or beneficial effects of a specific embodiment. In other embodiments, additional technical features and beneficial effects can also be identified in a specific embodiment that does not embody all embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 A flowchart of a method for storing permission data provided in an embodiment of the present application;
[0052] Figure 2 A schematic diagram of a data synchronization method provided in an embodiment of the present application;
[0053] Figure 3 A schematic diagram of another data synchronization method provided in an embodiment of the present application;
[0054] Figure 4 A flowchart of a method for retrieving permission data provided in an embodiment of the present application;
[0055] Figure 5 A schematic diagram of a storage device for permission data provided in an embodiment of the present application;
[0056] Figure 6 A schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0057] The terms "first", "second", "third", etc. in the specification of this application and the accompanying drawings are used to distinguish different objects rather than to limit a specific order.
[0058] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0059] In order to make the description of the following embodiments clear and concise, a brief introduction to the related technology is first given:
[0060] Permission data refers to the data of access or operation permissions related to a specific object (such as a user). Permission data can be stored in relational databases. For example, a user table and a permission table can be created, and the user table and the permission table can be associated through foreign keys to establish a relationship between users and permissions. During the storage process, permission data will be stored in the user table and the permission table in order. When searching for permission data of a specific user, the entire user table needs to be traversed. When there are many users recorded in the user table, the retrieval time is long and the retrieval efficiency is poor.
[0061] In view of this, an embodiment of the present application provides a method for storing permission data, which can be applied to electronic devices, wherein the electronic devices include terminals and servers, wherein the terminals include but are not limited to smart phones, tablet computers, laptops, personal digital assistants (PDAs) or smart wearable devices, etc. The server can be a cloud server, for example, a central server in a central cloud computing cluster, or an edge server in an edge cloud computing cluster. Of course, the server can also be a server in a local data center. A local data center refers to a data center directly controlled by a user. Specifically, the method includes:
[0062] The electronic device obtains first permission data of a first object, where the first permission data includes first identification information and first permission information of the first object, wherein the first identification information is used to uniquely identify the first object, and then based on the first identification information, a first storage address corresponding to the first permission data is calculated, and finally based on the first storage address, the first permission data is stored.
[0063] After the electronic device stores the permission data using the above method, in the subsequent retrieval process of the permission data, it can also first calculate the corresponding storage address based on the identification information, and then start retrieving the permission data from the storage address obtained based on the calculation. Compared with the retrieval method of traversing the entire database, the retrieval amount and retrieval time are shortened, and the retrieval efficiency is improved.
[0064] In order to make the technical solution of the present application clearer and easier to understand, the storage method of the permission data provided in the embodiment of the present application is introduced from the perspective of an electronic device. Figure 1 As shown, the figure is a flowchart of a method for storing permission data provided by an embodiment of the present application, the method comprising:
[0065] S101. An electronic device obtains first permission data of a first object.
[0066] The first object may refer to a user, or may refer to a role or identity of the user. A user may have at least one role or identity. For example, the first user includes a first role and a second role.
[0067] The first permission data refers to data on permissions such as access or operation related to the first object. The first permission data includes first identification information and first permission information. The first identification information is used to uniquely identify the first object.
[0068] When an electronic device needs to store the first permission data of a first object, it can first obtain the first permission data of the first object, for example, it can be the first permission data of the first object received from other electronic devices, or it can be the first permission data of the first object configured during the creation of a new account.
[0069] It should be noted that the present application does not specifically limit the manner in which the electronic device obtains the first authority data.
[0070] S102: The electronic device calculates a first storage address corresponding to the first permission data according to the first identification information.
[0071] After obtaining the first permission data, the electronic device may parse the first permission data to obtain the first identification information and first permission information in the first permission data, wherein the first permission information is used to indicate which permissions the first object has.
[0072] Since the first identification information is used to uniquely identify the first object, that is, different objects correspond to different identification information, based on this, the electronic device can calculate the first storage address corresponding to the first permission data based on the first identification information.
[0073] In some embodiments, the electronic device can calculate the first storage sub-address of the first identification information in the first array and the second storage sub-address of the first permission information in the second array based on the first identification information. The first array is used to store the identification information of the object, and the second array is used to store the permission information of the object. Exemplarily, the first array may include multiple sub-addresses, the second array may include multiple sub-addresses, and the lengths of the first array and the second array may be the same. For example, if the identification information of the first object is stored at the first sub-address (first position) of the first array, then the permission information of the first object is stored at the first sub-address (first position) of the second array, that is, the sub-addresses of the identification information and the permission information in their respective arrays correspond.
[0074] In some embodiments, the first identification information may be composed of numbers, and the electronic device may use the first identification information to perform a modulo operation on a preset reference value to obtain a modulo result, which is the first storage sub-address of the first identification information in the first array and the second storage sub-address of the first permission information in the second array. The preset reference value is a user-defined value.
[0075] For example, the first identification information is "1234", the preset reference value is "10", and the remainder result is "4", that is, the first identification information is stored at the 4th subaddress in the first array, and the first permission information is stored at the 4th subaddress in the second array.
[0076] Furthermore, after obtaining the modulo result, the electronic device can also determine whether the storage sub-address corresponding to the modulo result stores permission data. In some examples, the initial default value of each sub-address in the first array can be "-1". Continuing with the above example, after obtaining the modulo result "4", the electronic device can determine whether the value of the 4th sub-address in the first array is "-1". If so, the first identification information is stored in the 4th sub-address in the first array. If not, the preset reference value is increased by 1, and then the modulo operation is performed again to obtain a modulo result of "2". Then, it is determined whether the value of the 2nd sub-address in the first array is "-1". And so on, the first storage sub-address and the second storage sub-address corresponding to the first identification information are determined.
[0077] It should be noted that the above example is only introduced by determining the initial default value of each sub-address in the first array. It is also possible to determine whether permission data is stored by determining the initial default value of each sub-address in the second array. In addition, the initial value of the above preset reference value can be determined based on the length of the first array or the second array, thereby reducing the number of calculations and improving storage efficiency.
[0078] In another embodiment, the electronic device may calculate the first storage sub-address of the first identification information and the second storage sub-address of the first permission information according to the first identification information and the length of the first array, and the length of the first array is the same as that of the second array.
[0079] In some examples, the electronic device can use the first identification information to perform a modulo operation on the length of the first array to obtain a modulo result, which is the first storage sub-address of the first identification information in the first array and the second storage sub-address of the first permission information in the second array.
[0080] In other examples, the electronic device may first convert the first identification information into a binary number, and then use the odd bits (or even bits) of the binary number to perform a modulo operation on the length of the first array to obtain a modulo result.
[0081] In other examples, the electronic device may also perform encryption processing according to preset rules to obtain a new number, convert the new number into a binary number, and then use the odd bits (or even bits) of the binary number to perform a modulo operation on the length of the first array to obtain a modulo result.
[0082] Furthermore, after obtaining the modulo result, the electronic device can also determine whether the storage sub-address corresponding to the modulo result stores permission data. In some examples, the initial default value of each sub-address in the first array can be "-1". Continuing with the above example, after obtaining the modulo result (for example, 4), the electronic device can determine whether the value of the 4th sub-address in the first array is "-1". If so, the first identification information is stored in the 4th sub-address in the first array. If not, the modulo result is increased by 1, and then the judgment is made again based on the new modulo result until the value of the sub-address is not "-1", thereby determining the first storage sub-address and the second storage sub-address corresponding to the first identification information.
[0083] It should be noted that the present application does not specifically limit the method for determining the first storage sub-address and the second storage sub-address.
[0084] In some embodiments, in order to further improve the retrieval efficiency of the permission data retrieval process, the storage process of the permission data can also be divided into warehouses. Two different warehouse division methods are introduced below.
[0085] The first one:
[0086] The electronic device obtains the first creation time of the first object, and then determines the first storage area of the first permission data (i.e., which data warehouse to store it in) based on the first creation time, and then calculates the first storage address corresponding to the first permission data in the first storage area based on the first identification information.
[0087] The first creation time refers to the creation time of the first object, and the creation time can be maintained in a table, for example, including the first identification information of the user and the estimated first creation time. Exemplarily, a mapping relationship between the creation time and the storage area can be established in advance, for example, the storage area can be divided according to the quarter, month, and year to which the creation time belongs. Table 1 shows an example of dividing the storage area according to the quarter to which the creation time belongs.
[0088] Table 1:
[0089] Creation time Storage Area 2022-01-03 First storage area 2022-03-04 First storage area 2022-05-06 Second storage area … …
[0090] After obtaining the first creation time of the first object, the first storage area corresponding to the first creation time may be determined based on the mapping relationship shown in Table 1. In the first approach, subsequent data migration problems can be avoided, and data is continuous in time, which facilitates data observation.
[0091] Second type:
[0092] The electronic device randomly extracts an n-bit element from the first identification information, and then determines the first storage area of the first permission data according to the randomly extracted n-bit element. Exemplarily, the electronic device randomly extracts an n-bit element from the first identification information, and then adds the n-bit element to the ASCII code, and then divides the result of the addition by the number of storage areas, and obtains a result of the division, such as 1, and then determines that the storage area of the first permission data is the first storage area.
[0093] The second method does not need to introduce a new table to maintain the relationship between the creation time of the object and the identification information of the object, and is relatively simple to implement.
[0094] S103: The electronic device stores the first authority data according to the first storage address.
[0095] After determining the first storage address, the electronic device stores the first authority data according to the first storage address.
[0096] In some examples, after the electronic device determines the first storage sub-address and the second storage sub-address, it can store the first identification information to the first storage sub-address in the first array, and store the first permission information to the second storage sub-address in the second array. The position of the first storage sub-address in the first array and the position of the second storage sub-address in the second array are the same. For example, after the electronic device determines that the position of the first storage sub-address in the first array is the first position, the electronic device stores the first identification information to the first position of the first array, and stores the first permission information to the first position of the second array. Before storing, it is also necessary to determine whether other permission data is stored in the first position. The specific judgment process can be referred to the above example, which will not be repeated here.
[0097] Based on the above description, an embodiment of the present application provides a method for storing permission data. After an electronic device stores permission data through this method, in the subsequent retrieval process of the permission data, it can also first calculate the corresponding storage address based on the identification information, and then start retrieving the permission data from the storage address obtained based on the calculation. Compared with the retrieval method of traversing the entire database, the retrieval amount and retrieval time are shortened, and the retrieval efficiency is improved.
[0098] In some embodiments, the electronic device may store the user's permission data through Elasticsearch (a distributed search engine and analysis engine) and MySQL (a relational database). MySQL is first introduced below.
[0099] Multiple tables can be maintained in MySQL, such as User (user basic information table), UserDetail (user extended information table), Role (role table), UserRoleRelation (user role association table), Pagepermission (page permission table), InterfacePermission (interface permission table), RoleInterfacePermissionRelation (role interface permission association table), RolePagePermissionRelation (role page permission association table) and UserLoginLog (user login record table).
[0100] Among them, User (user basic information table) is used to record the basic information of users, including full field information such as account number, user password, email address and user operation password. UserDetail (user extended information table) contains information such as avatar address, gender, last login time, user personal motto, user nickname, device login status and user language. Role (role table) is used to record the role information of users, including role name, role code, module, label and description. UserRoleRelation (user role association table) is used to record which roles users are associated with, including the associated user ID and role ID (a user can be associated with multiple roles, and a role can also be associated with multiple users). Pagepermission (page permission table) is used to record page permission information, including page code, page remarks, page module, page name, parent code, page type and parent string (the parent page primary key ID is connected with commas in sequence to facilitate the retrieval of parent pages, for example: 3,15,16,23,). InterfacePermission (interface permission table) is used to record interface permission information, including interface code, interface remarks, method type, module, interface name and interface path. RoleInterfacePermissionRelation (Role interface permission association table) is used to record which interface permissions a role is associated with, including interface permission ID and role ID. RolePagePermissionRelation (Role page permission association table) is used to record which page permissions a role is associated with, including page permission ID and role ID. UserLoginLog (User login record table) is used to save relevant information of each user login, including login account type, user account, user nickname, user uuid, login time, login status (success / failure) and login address.
[0101] The design of Elasticsearch is introduced below. In this embodiment, a large wide table is used to store users and some user-related information that needs to be searched. The large wide table is a comprehensive information table that combines User table information, role table information, PagePermission table information, InterfacePermission table information and UserDetail table.
[0102] The advantages of using Elasticsearch in the embodiments of the present application include: being able to quickly retrieve and filter massive amounts of user data; being able to flexibly return data in specified columns and return data based on business dynamics; supporting full-text search, automatic word segmentation, and matching all eligible users according to keywords. The advantages of using MySQL include: ensuring data security and consistency, such as login and logout, being able to synchronize user login status and other information in real time to prevent unexpected status update operations; supporting transaction operations, being able to ensure data security in concurrent situations, such as the correctness of key and important attributes such as user information and user role permission configuration, and ensuring the reliability of key businesses such as login, logout, and permission configuration.
[0103] In order to ensure data consistency in MySQL and Elasticsearch, the embodiment of the present application also provides two data synchronization methods, which are introduced below.
[0104] The first one:
[0105] like Figure 2 As shown, this figure is a schematic diagram of a data synchronization method provided in an embodiment of the present application.
[0106] The electronic device can timely update the data in Elasticsearch through the binlog (a log file that records the changes made to the database by the user in MySQL) information of the user basic information table, user extended information table, role table, user role association table, page permission table, interface permission table, role interface permission association table, role page permission association table and user login record table in MySQL.
[0107] Second type:
[0108] like Figure 3 As shown, this figure is a schematic diagram of another data synchronization method provided in an embodiment of the present application.
[0109] After the contents of the user basic information table, user extended information table, role table, user role association table, page permission table, interface permission table, role interface permission association table, role page permission association table and user login record table in MySQL are modified, a command is sent to kafka (message middleware), and based on the command, the data in Elasticsearch is updated.
[0110] The storage method of permission data provided in the embodiments of the present application can improve the aggregation of the code, unify the entry, and facilitate later maintenance and expansion (defining some unique behaviors in the data model, such as obtaining basic user information at login, finding associated roles, obtaining interface permissions and page permissions that match the current role, etc., and other behaviors can be expanded according to business needs). The method also improves code reusability (it can be implemented through the data model in a variety of business scenarios. For example, when data related to user information is returned everywhere, it can be obtained through the information in the model). The method reduces complex SQL query statements in the database, such as subsequent permission matching, and calculates in memory, improving efficiency and reducing database pressure.
[0111] In other embodiments, the present application also provides a method for retrieving permission data, such as Figure 4 As shown, the figure is a flowchart of a method for retrieving permission data provided by an embodiment of the present application, the method comprising:
[0112] S201. The electronic device receives a search request.
[0113] The search request carries the second identification information of the second object. In some embodiments, when it is necessary to determine which permissions the second object has, a search request can be sent to an electronic device, and after receiving the search request, the electronic device can parse the search request to obtain the carried second identification information.
[0114] S202: The electronic device calculates a second storage address corresponding to second permission data of the second object according to the second identification information.
[0115] After obtaining the second identification information, the electronic device can calculate the second storage address corresponding to the second permission data of the second object based on the second identification information. The manner in which the electronic device determines the second storage address can refer to the above embodiment and will not be described again here.
[0116] S203: The electronic device retrieves second permission data corresponding to the second object from the second storage address.
[0117] After obtaining the second storage address, which includes a third storage sub-address and a fourth storage sub-address, the electronic device determines the position of the third storage sub-address in the first array, and then determines whether the identification information stored at the position is the second identification information. If so, the second permission information is obtained from the corresponding position in the second array (the position corresponding to the fourth storage sub-address in the second array), and then the second permission data (including the second identification information and the second permission information) is returned; if not, the second storage address can be re-determined, or the next address of the second storage address can be retrieved until the stored identification information is consistent with the second identification information, and then the corresponding permission data is returned.
[0118] In the method for retrieving permission data provided in the embodiment of the present application, there is no need to traverse the entire database. Instead, the location where the permission data is stored is first determined, and then the search is started from that location, thereby reducing the search amount, shortening the search time, and improving the search efficiency.
[0119] Combination of the above Figures 1 to 4 The storage method of the permission data provided in the embodiment of the present application is introduced in detail. The apparatus and device provided in the embodiment of the present application will be introduced in conjunction with the accompanying drawings.
[0120] like Figure 5 As shown, the figure is a schematic diagram of the structure of a storage device for permission data provided in an embodiment of the present application, and the device includes:
[0121] An acquisition module 501 is configured to acquire first permission data of a first object, where the first permission data includes first identification information and permission information of the first object, where the first identification information is used to uniquely identify the first object;
[0122] A calculation module 502, configured to calculate a first storage address corresponding to the first permission data according to the first identification information;
[0123] The storage module 503 is used to store the first permission data according to the first storage address.
[0124] In some possible implementations, the calculation module 502 is specifically used to calculate, based on the first identification information, a first storage sub-address of the first identification information in the first array and a second storage sub-address of the first permission information in the second array; the storage module 503 is specifically used to store the first identification information in the first array based on the first storage sub-address, and store the first permission information in the second array based on the second storage sub-address.
[0125] In some possible implementations, the calculation module 502 is specifically used to use the first identification information to perform a modulo operation on a preset reference value to obtain a modulo result, wherein the modulo result is the first storage sub-address of the first identification information in the first array and the second storage sub-address of the first permission information in the second array.
[0126] In some possible implementations, the calculation module 502 is specifically used to calculate the first storage sub-address of the first identification information and the second storage sub-address of the first permission information based on the first identification information and the length of the first array, and the length of the first array is the same as that of the second array.
[0127] In some possible implementations, the device further includes: a receiving module and a retrieving module;
[0128] The receiving module is used to receive a retrieval request, which carries the second identification information of the second object; the calculation module 502 is also used to calculate the second storage address corresponding to the second permission data of the second object based on the second identification information; the retrieval module is used to retrieve the second permission data of the second object from the second storage address.
[0129] In some possible implementations, the device further includes a determination module;
[0130] The acquisition module 501 is also used to obtain the first creation time of the first object; the determination module is used to determine the first storage area of the first permission data based on the first creation time; the calculation module 502 is specifically used to calculate the first storage address corresponding to the first permission data in the first storage area based on the first identification information.
[0131] In some possible implementations, the apparatus further includes: a determination module;
[0132] The acquisition module 501 is used to randomly extract an n-bit element from the first identification information; the determination module is used to determine the first storage area of the first permission data based on the randomly extracted n-bit element; the calculation module 502 is specifically used to calculate the first storage address corresponding to the first permission data in the first storage area based on the first identification information.
[0133] The storage device for permission data according to the embodiment of the present application may correspond to executing the method described in the embodiment of the present application, and the above and other operations and / or functions of each module / unit of the storage device for permission data are respectively to implement Figure 1 , Figure 4 For the sake of brevity, the corresponding processes of each method in the illustrated embodiment are not described in detail here.
[0134] The present application also provides an electronic device. The electronic device is specifically used to implement Figure 5 The function of the storage device for authority data in the illustrated embodiment.
[0135] like Figure 6 As shown in FIG. 1 , this figure is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, such as Figure 6 As shown, the electronic device 700 includes a bus 701, a processor 702, a communication interface 703 and a memory 704. The processor 702, the memory 704 and the communication interface 703 communicate with each other via the bus 701.
[0136] The bus 701 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, and a control bus. For ease of representation, Figure 6 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0137] The processor 702 may be any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0138] The communication interface 703 is used to receive a search request or permission data, and may also transmit permission data, etc.
[0139] The memory 704 may include a volatile memory, such as a random access memory (RAM). The memory 704 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).
[0140] The memory 704 stores executable codes, and the processor 702 executes the executable codes to perform the aforementioned permission data storage method.
[0141] Specifically, in implementing Figure 5 In the case of the embodiment shown, and Figure 5 When each module or unit of the storage device for permission data described in the embodiment is implemented by software, the execution Figure 5 The software or program code required for the functions of each module / unit in the system may be partially or completely stored in the memory 704. The processor 702 executes the program code corresponding to each unit stored in the memory 704 and executes the aforementioned storage method for permission data.
[0142] The embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that can be stored by the electronic device or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (such as a floppy disk, a hard disk, a tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid-state hard disk). The computer-readable storage medium includes instructions that instruct the electronic device to execute the above-mentioned storage method for permission data of the storage device for permission data.
[0143] The embodiment of the present application further provides a computer program product, which includes one or more computer instructions. When the computer instructions are loaded and executed on an electronic device, the process or function described in the embodiment of the present application is generated in whole or in part.
[0144] The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website, computer or data center to another website, computer or data center via wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means.
[0145] When the computer program product is executed by a computer, the computer executes any of the aforementioned methods for storing permission data. The computer program product may be a software installation package, and when any of the aforementioned methods for storing permission data is required, the computer program product may be downloaded and executed on a computer.
[0146] The descriptions of the processes or structures corresponding to the above-mentioned figures have different emphases. For parts that are not described in detail in a certain process or structure, please refer to the relevant descriptions of other processes or structures.
[0147] The above description is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application.
Claims
1. A method for storing permission data, characterized in that: The method comprises: Acquire first permission data of a first object, where the first permission data includes first identification information and first permission information of the first object, where the first identification information is used to uniquely identify the first object; Calculating a first storage address corresponding to the first permission data according to the first identification information; storing the first permission data according to the first storage address; The calculating, according to the first identification information, a first storage address corresponding to the first permission data includes: Calculate, according to the first identification information, a first storage sub-address of the first identification information in the first array and a second storage sub-address of the first permission information in the second array; The storing the first permission data according to the first storage address includes: storing the first identification information into the first array according to the first storage sub-address, and storing the first permission information into the second array according to the second storage sub-address; The step of calculating, according to the first identification information, a first storage sub-address of the first identification information in the first array and a second storage sub-address of the first permission information in the second array includes: Calculating a first storage sub-address of the first identification information and a second storage sub-address of the first permission information according to the first identification information and the length of the first array, wherein the first array has the same length as the second array; The process of calculating the first storage sub-address of the first identification information and the second storage sub-address of the first permission information according to the first identification information and the length of the first array includes: Convert the first identification information into a binary number, and perform a modulo operation on the length of the first array using odd or even bits of the binary number to obtain a modulo result, where the modulo result is a first storage sub-address of the first identification information in the first array and a second storage sub-address of the first permission information in the second array; The method further comprises: Obtaining a value of a first storage sub-address in the first array; The step of storing the first identification information into the first array according to the first storage sub-address, and storing the first permission information into the second array according to the second storage sub-address includes: If the value of the first storage sub-address in the first array is consistent with the initial default value, the first identification information is stored in the first array according to the first storage sub-address, and the first permission information is stored in the second array according to the second storage sub-address.
2. The method according to claim 1, characterized in that The method further comprises: receiving a search request, wherein the search request carries second identification information of a second object; Calculating, according to the second identification information, a second storage address corresponding to the second permission data of the second object; The second permission data of the second object is retrieved from the second storage address.
3. The method according to claim 1, characterized in that The method further comprises: Obtaining a first creation time of the first object; Determining a first storage area for the first permission data according to the first creation time; The calculating, according to the first identification information, a first storage address corresponding to the first permission data includes: A first storage address corresponding to the first permission data in the first storage area is calculated according to the first identification information.
4. The method according to claim 1, characterized in that: The method further comprises: Randomly extracting n-bit elements from the first identification information; Determining a first storage area for the first permission data according to the randomly selected n-bit element; The calculating, according to the first identification information, a first storage address corresponding to the first permission data includes: A first storage address corresponding to the first permission data in the first storage area is calculated according to the first identification information.
5. A storage device for authority data, characterized in that: The device comprises: An acquisition module, configured to acquire first permission data of a first object, wherein the first permission data includes first identification information and permission information of the first object, and the first identification information is used to uniquely identify the first object; a calculation module, configured to calculate a first storage address corresponding to the first permission data according to the first identification information; a storage module, configured to store the first permission data according to the first storage address; The calculation module is specifically configured to calculate, according to the first identification information, a first storage sub-address of the first identification information in the first array and a second storage sub-address of the first permission information in the second array; The storage module is specifically configured to store the first identification information into the first array according to the first storage sub-address, and store the first permission information into the second array according to the second storage sub-address; The calculation module is specifically configured to calculate a first storage sub-address of the first identification information and a second storage sub-address of the first permission information according to the first identification information and a length of the first array, wherein the first array has the same length as the second array; convert the first identification information into a binary number, and perform a modulo operation on the length of the first array using odd or even bits of the binary number to obtain a modulo result, wherein the modulo result is the first storage sub-address of the first identification information in the first array and the second storage sub-address of the first permission information in the second array; The acquisition module is further used to acquire the value of the first storage sub-address in the first array; The storage module is specifically used to store the first identification information in the first array according to the first storage sub-address, and store the first permission information in the second array according to the second storage sub-address if the value of the first storage sub-address in the first array is consistent with the initial default value.
6. An electronic device, characterized in that: including memory and processor; One or more computer programs are stored in the memory, and the one or more computer programs include instructions; when the instructions are executed by the processor, the electronic device executes the method as claimed in any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method according to any one of claims 1 to 4.
