Resource receiving data storage method and device, electronic equipment and storage medium
By converting the character encoding of resource-acquisition data in the banking system into binary encoding and using the message queue system to process concurrent requests, the problem of excessive database space occupied by resource-acquisition data is solved, and storage efficiency and system performance are improved.
Patent Information
- Application Number
- CN202411256641.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-06
- Publication Date
- 2024-12-31
AI Technical Summary
In the banking system, resource collection data occupies too much database storage space, resulting in low storage efficiency and system performance degradation.
By converting the resource acquisition time from character encoding to binary encoding, and splicing and filling according to the time representation format, the target time code is generated, the storage space occupation is reduced, and the message queue system is used to process concurrent requests to improve system performance.
It effectively reduces the storage space occupied by resource acquisition data in the database, improves data processing efficiency and system performance, and avoids repeated resource acquisition and database pressure.
Smart Images

Figure CN119226371A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of financial technology, and in particular to a method and device for storing resource collection data, an electronic device and a storage medium. Background Art
[0002] The banking system provides users with various resources to collect, such as some shopping coupons, to promote user stickiness to banking financial services. When a large number of users log in to the banking system to collect resources, a large amount of resource collection data will be generated. In order to avoid users from repeatedly collecting resources, the resource collection data needs to be stored in the database so that it is easy to determine whether users have repeatedly collected resources. However, these resource collection data will occupy a large amount of storage space in the database. Summary of the invention
[0003] The main purpose of the embodiments of the present application is to provide a storage method and device, electronic device and storage medium for resource collection data, aiming to reduce the storage space occupied by resource collection data in the database.
[0004] To achieve the above purpose, a first aspect of an embodiment of the present application proposes a method for storing resource claiming data, the method comprising:
[0005] Obtain a resource collection request from a target object; the resource collection request includes a target object identifier and a resource collection time of the target object;
[0006] Acquire the data format of the resource collection time, obtain the collection time character and the time representation format of the collection time character;
[0007] Bit-encoding the collection time character according to the time representation format to obtain a binary time code of the collection time character;
[0008] splicing the binary time codes according to the time representation format to obtain a target time code for the resource collection time;
[0009] Generate resource collection data according to the target object identifier and the target time code;
[0010] The resource claim data is stored in a preset database.
[0011] In some embodiments, the acquiring of the data format of the resource collection time, obtaining the collection time character and the time representation format of the collection time character, includes:
[0012] The preset message queue system is screened according to the resource collection time to obtain a target message queue;
[0013] The resource claim request is stored in the target message queue, and the queue length of the target message queue is obtained;
[0014] The data format of the resource collection time is acquired according to the queue length, and the collection time character and the time representation format are obtained.
[0015] In some embodiments, bit encoding the collection time character according to the time representation format to obtain a binary time code of the collection time character includes:
[0016] Obtaining the number of bits of the bit encoding of the collection time character according to the time representation format;
[0017] The collection time characters are bit-encoded according to the bit encoding bit number to obtain the binary time code.
[0018] In some embodiments, after storing the resource claiming data in a preset database, the method includes:
[0019] Acquire a reference pick-up request for a target object, wherein the reference pick-up request includes the target object identifier and a reference pick-up time of the target object;
[0020] Query the preset database according to the target object identifier to obtain the target time code;
[0021] Generate reference pickup data according to the target object identifier, the reference pickup time and the target time code;
[0022] The reference collection data is stored in the preset database.
[0023] In some embodiments, generating reference pickup data according to the target object identifier, the reference pickup time, and the target time code includes:
[0024] Bit encoding the reference pickup time to obtain a reference time code of the reference pickup time;
[0025] comparing the reference time code and the target time code;
[0026] If the reference time code and the target time code are not the same, the reference collection data is generated according to the target object identifier and the reference time code.
[0027] In some embodiments, the step of splicing the binary time codes according to the time representation format to obtain the target time code of the resource collection time includes:
[0028] splicing the binary time codes according to the time representation format to obtain a spliced time code;
[0029] The splicing time code is filled to obtain the target time code.
[0030] In some embodiments, after storing the resource claiming data in a preset database, the method further includes:
[0031] Obtaining the storage duration of storing the resource claim data in a preset database;
[0032] If the storage duration is greater than the preset duration, reading the resource claiming data from the preset database;
[0033] The resource claim data is stored in a target database; wherein the target database is different from the preset database.
[0034] To achieve the above-mentioned purpose, a second aspect of an embodiment of the present application provides a storage device for resource claiming data, the device comprising:
[0035] A first acquisition module is used to acquire a resource collection request of a target object; the resource collection request includes a target object identifier and a resource collection time of the target object;
[0036] A second acquisition module is used to acquire the data format of the resource collection time, obtain the collection time character and the time representation format of the collection time character;
[0037] An encoding module, used for performing bit encoding on the collection time character according to the time representation format to obtain a binary time code of the collection time character;
[0038] A splicing module, used for splicing the binary time codes according to the time representation format to obtain a target time code for the resource collection time;
[0039] A generating module, used for generating resource collection data according to the target object identifier and the target time code;
[0040] The storage module is used to store the resource claim data in a preset database.
[0041] To achieve the above objectives, a third aspect of an embodiment of the present application proposes an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the method described in the first aspect is implemented.
[0042] To achieve the above-mentioned purpose, the fourth aspect of an embodiment of the present application proposes a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect is implemented.
[0043] The storage method for resource collection data, the storage device for resource collection data, the electronic device and the computer-readable storage medium proposed in the embodiment of the present application obtain the resource collection request of the target object, so as to provide various resources to the target object based on the resource collection request. The resource collection request includes the target object identifier and the resource collection time of the target object, obtains the data format of the resource collection time, obtains the collection time character and the time representation format of the collection time character. Using the character format to store the resource collection time will occupy a large storage space. In order to save the storage space of the database, the collection time character is bit-encoded according to the time representation format, and the collection time character is converted from the character encoding mode to the binary encoding mode to obtain the binary time code of the collection time character. The binary time code adopts the binary representation mode, and the storage space occupied by the collection time character is greatly reduced by using only two digits 0 and 1 to represent the collection time character. In order to obtain a complete time code, the binary time code is spliced according to the time representation format to obtain the target time code of the resource collection time. Generate resource collection data according to the target object identifier and the target time code, store the resource collection data in a preset database, and reduce the storage space occupied by the resource collection data in the database. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 is a flowchart of a method for storing resource claim data provided in an embodiment of the present application;
[0045] Figure 2 yes Figure 1 Flow chart of step S120 in FIG.
[0046] Figure 3 yes Figure 1 Flow chart of step S130 in FIG.
[0047] Figure 4 yes Figure 1 Flow chart of step S140 in FIG.
[0048] Figure 5 is another flow chart of the method for storing resource claim data provided in an embodiment of the present application;
[0049] Figure 6 yes Figure 5 Flow chart of step S530 in FIG.
[0050] Figure 7 is another flow chart of the method for storing resource claim data provided in an embodiment of the present application;
[0051] Figure 8 It is a structural diagram of a storage device for resource collection data provided in an embodiment of the present application;
[0052] Fig. 9 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0054] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0055] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0056] The banking system provides users with various resources to collect, such as some shopping coupons, to promote user stickiness to banking financial services. When a large number of users log in to the banking system to collect resources, a large amount of resource collection data will be generated. In order to avoid users from repeatedly collecting resources, the resource collection data needs to be stored in the database so that it is easy to determine whether users have repeatedly collected resources. However, these resource collection data will occupy a large amount of storage space in the database.
[0057] Based on this, the embodiments of the present application provide a method and device for storing resource collection data, an electronic device and a storage medium, aiming to reduce the storage space occupied by resource collection data in the database.
[0058] The storage method and device for resource collection data, electronic device and storage medium provided in the embodiments of the present application are specifically described through the following embodiments. First, the storage method for resource collection data in the embodiments of the present application is described.
[0059] The storage method for resource collection data provided in the embodiment of the present application relates to the field of financial technology technology. The storage method for resource collection data provided in the embodiment of the present application can be applied to a terminal, can be applied to a server side, or can be software running in a terminal or a server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or can be configured as a server cluster or a distributed system composed of multiple physical servers, or can be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the storage method for resource collection data, etc., but is not limited to the above forms.
[0060] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0061] Figure 1 is an optional flowchart of the method for storing resource collection data provided in an embodiment of the present application. Figure 1 The method may include but is not limited to steps S110 to S160.
[0062] Step S110, obtaining a resource collection request of a target object; the resource collection request includes a target object identifier and a resource collection time of the target object;
[0063] Step S120, obtaining the data format of the resource collection time, obtaining the collection time character and the time representation format of the collection time character;
[0064] Step S130, bit-encoding the collection time character according to the time representation format to obtain a binary time code of the collection time character;
[0065] Step S140, splicing the binary time codes according to the time representation format to obtain the target time code of the resource collection time;
[0066] Step S150, generating resource collection data according to the target object identifier and the target time code;
[0067] Step S160, storing the resource claiming data into a preset database.
[0068] Steps S110 to S160 shown in the embodiment of the present application greatly reduce the storage space occupied by the resource collection time by converting the resource collection time from a character encoding method to a binary encoding method, so as to facilitate storing a large amount of resource collection data in the database.
[0069] In step S110 of some embodiments, the target object clicks the collection button on the resource collection page provided by the bank system to generate a resource collection request. The resource collection request is a request initiated by the target object through the client to collect the corresponding resource. The resource collection request includes the target object identifier and resource collection time of the target object. The target object may be a user of the bank system. The target object identifier is a unique identifier assigned to the user by the bank system, which may be the user name, phone number, application account number, bank account number, etc. of the target object. The resource collection time is the time when the target object collects the resource. The resource includes but is not limited to funds, coupons, red envelopes, gifts, etc. provided to the user by the bank system. The resource can be used to deduct the value of the item when the target object creates a shopping order.
[0070] See also Figure 2 In some embodiments, step S120 may include but is not limited to steps S210 to S230:
[0071] Step S210, screening the preset message queue system according to the resource collection time to obtain the target message queue;
[0072] Step S220, storing the resource claim request in the target message queue, and obtaining the queue length of the target message queue;
[0073] Step S230, obtaining the data format of the resource collection time according to the queue length, and obtaining the collection time character and time representation format.
[0074] In step S210 of some embodiments, when a large number of target objects log in to the bank system to collect resources at the same time, the bank system will face a high concurrency situation, which reduces the system's processing efficiency for resource collection requests. In order to improve system performance, the embodiment of the present application introduces a message queue system as a temporary buffer to temporarily store a large number of concurrent requests. The message queue system includes multiple message queues, each of which is used to store resource collection requests for a specific resource collection time. A large number of users will try to collect resources at the same time, so that the resource collection time of a large number of resource collection requests is the same. In order to improve the storage efficiency of resource collection data, the number of requests for the current resource collection request is obtained. If the number of requests is greater than or equal to the preset number threshold, the message queue system is screened according to the resource collection time to store multiple resource collection requests with the same resource collection time in the same message queue to obtain the target message queue. The preset number threshold can be set according to actual conditions, and the preset number threshold can be the maximum number of requests that the bank system can process simultaneously for multiple resource collection requests. If the number of requests is less than the preset number threshold, the resource collection request is directly processed.
[0075] In step S220 of some embodiments, the resource collection request is stored in a target message queue, and the target message queue stores multiple resource collection requests with the same resource collection time. The number of resource collection requests stored in the target message queue is obtained to obtain the queue length of the target message queue.
[0076] In step S230 of some embodiments, if the queue length is less than or equal to a preset length threshold, the data format of the resource collection time is obtained, and the collection time character and time representation format are obtained. The preset length threshold is the maximum number of resource collection requests that the target message queue can store, the preset length threshold is less than or equal to the preset number threshold, and the data format refers to the encoding method used when the data is stored. The resource collection time is usually stored in the form of a string string, and the collection time character is a character sequence that constitutes the resource collection time. The time representation format is used to represent the time attribute of the collection time character, such as year, month, day, hour, etc. If the queue length is greater than the preset length threshold, another message queue is selected from the message queue system, and after the capacity of the target message queue is expanded according to the other message queue, the data format of the resource collection time is obtained, and the collection time character and time representation format are obtained.
[0077] In the above steps S210 to S230, multiple resource collection requests with the same resource collection time can be processed through the message queue, thereby improving the processing efficiency of the resource collection requests and further improving the overall performance and concurrency capability of the system.
[0078] The resource collection time is usually stored in the form of a string, which occupies a lot of memory. Taking 3:00 p.m. on November 1, 2023 as an example, its string storage method is "20231101*15", where * represents a space. Due to memory alignment mechanism, special encoding mechanism and other reasons, string storage requires an additional 40 bytes of fixed overhead. "20231101*15" has a total of 11 characters, each character occupies two bytes, and a total of 62 bytes (496 bytes) are required. Since the resource collection time occupies a lot of memory, it is not conducive to saving resource collection data of a large number of users. In order to reduce the storage space occupied by the resource collection time, the collection time characters are bit-encoded according to the time representation format. In addition, since each resource collection time in the target message queue is the same, any resource collection time in the target message queue can be selected and bit-encoded, so that multiple different users can share the same encoding process to improve the processing efficiency of the resource collection time, thereby improving the storage efficiency of the resource collection data.
[0079] See also Figure 3 In some embodiments, step S130 may include but is not limited to steps S310 to S320:
[0080] Step S310, obtaining the bit encoding digit of the collection time character according to the time representation format;
[0081] Step S320, bit-encode the receiving time characters according to the bit encoding bit number to obtain a binary time code.
[0082] In step S310 of some embodiments, the number of bits of bit encoding is the number of bits required to represent the characters of the collection time in binary. The resource collection service provided by the banking system has a clear start time and end time. The service will not exist in 100 years. Therefore, if the time representation format is year, the thousands and hundreds of the year are not recorded, and only the last two characters of the characters of the collection time representing the ones and tens are extracted. For example, the last two characters of 2023 are 23, and the maximum value corresponding to the last two characters is 99. In order to represent 99 different years, the number of bits of bit encoding is 8. If the time representation format is month, there are 12 months in a year. In order to represent 12 different months, the number of bits of bit encoding is determined to be 4. If the time representation format is day, there are at most 31 days in a month. In order to represent 31 different days, the number of bits of bit encoding is determined to be 5. If the time representation format is hour, there are at most 24 hours in a day. In order to represent 24 different hours, the number of bits of bit encoding is determined to be 5.
[0083] In step S320 of some embodiments, the collection time characters are encoded into binary values according to the bit encoding digits to obtain a binary time code. If the resource collection time is "20230730*15", the collection time characters are 2023, 07, 30 and 15 respectively, and the time representation formats are year, month, day and hour respectively. The bit encoding digits of each collection time character are determined to be 8, 4, 5 and 5 respectively according to the time representation format. 23 is encoded as an 8-bit binary value to obtain a binary time code of 00010111. 07 is encoded as a 4-bit binary value to obtain a binary time code of 0111. 30 is encoded as a 5-bit binary value to obtain a binary time code of 11110. 15 is encoded as a 5-bit binary value to obtain a binary time code of 01111.
[0084] Through the above steps S310 to S320, the collection time characters can be converted into binary values according to the numerical characteristics of the time representation format such as year, month, day, etc., thereby reducing the storage space of the collection time characters.
[0085] See also Figure 4 In some embodiments, step S140 may include but is not limited to steps S410 to S420:
[0086] Step S410, splicing the binary time code according to the time representation format to obtain a spliced time code;
[0087] Step S420, filling the splicing time code to obtain the target time code.
[0088] In step S410 of some embodiments, the binary time codes of the collection time characters are spliced in the order of year, month, day, and hour according to the time representation format to obtain a spliced time code. The spliced time code is a 22-bit binary number. If the resource collection time is "20230730*15", the binary time codes of each collection time character are 00010111, 0111, 11110, and 01111. Each binary time code is spliced in the order of year, month, day, and hour to obtain a spliced time code of 0001011101111111001111.
[0089] In step S420 of some embodiments, in order to improve the read and write efficiency of the database and optimize the memory access speed, 0 is filled in front of the splicing time code for data alignment to obtain the target time code. The target time code is a 24-bit binary number. A byte consists of eight bits (bit), and the splicing time code is a 22-bit binary number. By filling zeros in front of the splicing time code, the splicing time code occupies a full three bytes. For example, the splicing time code 0001011101111111001111 can be filled with 000001011101111111001111. If the resource collection time is stored in the original string storage method, 496 bits are required, while the embodiment of the present application encodes the resource collection time as a special binary date and time character, which only requires 24 bits, greatly reducing the storage space of the resource collection time.
[0090] Through the above steps S410 to S420, the complete time code of the resource collection time can be obtained, and the reading and writing efficiency of the resource collection data is improved through data alignment.
[0091] In step S150 of some embodiments, the target object identifier and the target time code are used as resource collection data. Alternatively, the resource collection template includes an object identifier field, a resource collection time field, a resource type field, etc. The target object identifier is filled into the object identifier field of the resource collection template, and the target time code is filled into the resource collection time field of the resource collection template to obtain the resource collection data.
[0092] In step S160 of some embodiments, the bank system allows the target object to collect resources at different time points or time periods, but does not allow repeated collection of resources at the same time point or time period. The resource collection data is stored in a preset database, indicating that the target object has completed the resource collection task corresponding to the resource collection request, and the resources are distributed to the target object's object account resource pool, so as to query whether the target object has repeatedly collected resources based on the storage record of the resource collection data. The preset database can use different types of databases such as relational databases, non-relational databases, and distributed databases. The relational database can be a MySQL database or an Oracle database. The non-relational database can be a MongoDB database or a Red is database. The distributed database can use a database that can provide distributed database services, such as a MongoDB database or a Red is database.
[0093] See also Figure 5 In some embodiments, after step S160, the method for storing resource claim data may include but is not limited to steps S510 to S540:
[0094] Step S510, obtaining a reference pick-up request of a target object, the reference pick-up request including a target object identifier and a reference pick-up time of the target object;
[0095] Step S520, querying a preset database according to the target object identifier to obtain a target time code;
[0096] Step S530, generating reference collection data according to the target object identifier, the reference collection time and the target time code;
[0097] Step S540, storing the reference collection data into a preset database.
[0098] In step S510 of some embodiments, the target object clicks the collect button on the resource collection page to request to collect the resource, and obtains a reference collection request. The reference collection request and the resource collection request are two requests for collecting the corresponding resources generated by the client in different time sequences, and the time sequence of the reference collection request is after the resource collection request. The reference collection request includes the target object identifier and the reference collection time of the target object, and the reference collection time is the time when the target object collects the resource, and the reference collection time is after the resource collection time.
[0099] In step S520 of some embodiments, a preset database is queried according to the target object identifier, and if the preset database stores the resource collection data of the target object, the target time code in the resource collection data is obtained. If the preset database does not store the resource collection data of the target object, it means that the target object has never performed a resource collection operation, then in response to the reference collection request, refer to steps S120 to S140, bit-code the reference collection time, obtain the binary number of the reference collection time, use the binary number as the reference time code, store the target object identifier and the reference time code as resource collection data in the preset database, and issue the resource to the target object.
[0100] In step S530 of some embodiments, in order to prevent the target object from repeatedly claiming resources at the same time, the reference claim time is verified according to the target time code. If the verification passes, it means that the target object has not repeatedly claimed the resource, and reference claim data is generated according to the target object identifier and the reference claim time. The reference claim data is information generated according to the reference claim request to indicate that the resource claim task has been completed. If the verification fails, it means that the target object has repeatedly claimed the resource, and the reference claim request of the target object is rejected, and a prompt message is sent to the target object. The prompt message is used to inform the target object that the resource has been successfully claimed and cannot be claimed repeatedly.
[0101] In step S540 of some embodiments, the reference collection data is stored in a preset database to indicate that the target object has completed the resource collection task corresponding to the reference collection request.
[0102] Through the above steps S510 to S540, it is possible to determine whether the user has repeatedly received resources by querying the storage records of the preset database, thereby ensuring the accuracy and rationality of resource allocation.
[0103] See also Figure 6 In some embodiments, step S530 includes but is not limited to steps S610 to S630:
[0104] Step S610, bit-encoding the reference collection time to obtain a reference time code of the reference collection time;
[0105] Step S620, comparing the reference time code and the target time code;
[0106] Step S630: If the reference time code and the target time code are not the same, reference collection data is generated according to the target object identifier and the reference time code.
[0107] In step S610 of some embodiments, referring to steps S120 to S140, the reference collection time is bit-encoded to obtain a binary bit code of the reference collection time, thereby obtaining a reference time code. The reference time code is a 24-bit binary number.
[0108] In step S620 of some embodiments, in order to determine whether the target object repeatedly claims the resource multiple times at the same time, the reference time code and the target time code are compared.
[0109] In step S630 of some embodiments, if the reference time code and the target time code are different, it means that the target object has not repeatedly claimed the resource, and then the reference claiming data is generated according to the target object identifier and the reference time code. The generation method of the reference claiming data is the same as that of the resource claiming data, which can be referred to step S150 and will not be repeated here. If the reference time code and the target time code are the same, it means that the target object has repeatedly claimed the resource, and then the reference claiming request of the target object is rejected.
[0110] Through the above steps S610 to S630, it is possible to determine whether a user has repeatedly claimed resources, thereby preventing the same user from claiming resources multiple times at the same time, thereby ensuring the accuracy and rationality of resource allocation.
[0111] See also Figure 7 In some embodiments, after step S160, the method for storing resource claim data may also include but is not limited to steps S710 to S730:
[0112] Step S710, obtaining the storage duration of the resource claim data stored in the preset database;
[0113] Step S720, if the storage duration is greater than the preset duration, reading resource claim data from the preset database;
[0114] Step S730, storing the resource claiming data in a target database; wherein the target database is different from the preset database.
[0115] In step S710 of some embodiments, in order to attract users to participate in resource collection tasks at a specific time, resource collection tasks are usually time-limited activities, which makes the resource collection data of historical time usually not frequently accessed. When determining whether the user has repeatedly collected resources, it is necessary to query the latest resource collection data saved in the database. In order to improve the query performance of the database, the storage time of the resource collection data stored in the preset database is obtained.
[0116] In step S720 of some embodiments, if the storage duration is greater than the preset duration, it means that the resource collection data is old data that is not frequently accessed, and the resource collection data is read from the preset database. If the storage duration is less than or equal to the preset duration, it means that the resource collection data is new data that needs to be frequently accessed, and the resource collection data is not processed. The preset duration can be set according to the time limit of the resource collection task. For example, if the resource collection task is to collect resources once every hour, the preset duration can be one hour.
[0117] In step S730 of some embodiments, the resource claim data is stored in a target database, which is another database different from the preset database, and the performance of the preset database (such as using faster storage technology, more memory, etc.) may be better than the target database. It should be noted that new data requires more frequent access and faster query response time, and the new data can be stored in a preset database with better performance to support more complex queries, big data analysis or real-time processing, while old data will not be frequently accessed and can be stored in a target database with suboptimal performance requirements.
[0118] Through the above steps S710 to S730, the query efficiency of the latest resource collection data can be improved, so as to quickly determine whether the user has repeatedly collected resources, thereby improving the storage efficiency of the resource collection data.
[0119] The banking system will design hourly resource collection tasks, such as logging into the system every hour to collect resources, to promote user stickiness to the banking system's financial services. Due to the large number of users, there are a large number of users logging into the system at the same time, and the system will face high concurrency. For example, every time a user performs a resource collection task, it is necessary to query whether the user has completed the resource collection task within the current hour through database records, which makes the system performance worse and easily causes database congestion or database crash. At this time, the system generally chooses to use the String method to save the customer number and resource collection time, so that the system can check before querying the database to find out whether the user has completed the resource collection record, reducing the query pressure on the database. Using the String type to save the resource collection time will take up more memory. Taking "20231101*15" as an example, it takes up 62 bytes. Since each user generates a new data every hour, this storage method is not conducive to saving a large number of users' resource collection data in the database.
[0120] The storage method of resource collection data of the embodiment of the present application includes: obtaining a resource collection request from a target object, the resource collection request including a target object identifier and a resource collection time of the target object. A preset database is queried according to the target object identifier. If the resource collection data of the target object does not exist in the preset database, it means that the target object has not completed the resource collection task, and then the data format of the resource collection time is obtained to obtain the collection time character and the time representation format of the collection time character. If the time representation format of the current collection time character is year, the last two characters of the collection time character are extracted, and the last two characters are encoded into 8-bit binary digits to obtain the binary time code of the current collection time character. If the time representation format of the current collection time character is month, the collection time character is encoded into a 4-bit binary digit to obtain the binary time code of the current collection time character. If the time representation format of the current collection time character is day or hour, the current collection time character is encoded into a 5-bit binary digit to obtain the binary time code of the current collection time character. The binary time codes of each collection time character are spliced in the order of year, month, day, and hour, and the spliced binary time code is filled with 0 to obtain the target time code, so that the resource collection time of each user can be stored in a three-byte array. The target time code is updated to the cache completion record of the target object in the form of a byte array to indicate that the target object has completed the resource collection task this time. If the resource collection data of the target object exists in the preset database, the target time code of the resource collection data most recently stored in the preset database is obtained, and the resource collection time is bit-encoded to obtain the current target time code. In order to prevent the target object from repeatedly collecting resources within the same hour, the old target time code and the current target time code are compared. If the two are the same, the resource collection request of the target object is rejected. If the two are not the same, the target object identifier and the current target time code are stored as resource collection data in the preset database.
[0121] See also Figure 8 The embodiment of the present application also provides a storage device for resource collection data, which can implement the above-mentioned resource collection data storage method, and the device includes:
[0122] The first acquisition module 810 is used to acquire a resource collection request of a target object; the resource collection request includes a target object identifier and a resource collection time of the target object;
[0123] The second acquisition module 820 is used to acquire the data format of the resource collection time, and obtain the collection time character and the time representation format of the collection time character;
[0124] The encoding module 830 is used to perform bit encoding on the collection time character according to the time representation format to obtain a binary time code of the collection time character;
[0125] A splicing module 840 is used to splice the binary time code according to the time representation format to obtain a target time code of the resource collection time;
[0126] A generating module 850, for generating resource collection data according to a target object identifier and a target time code;
[0127] The storage module 860 is used to store the resource claim data in a preset database.
[0128] The specific implementation of the storage device for resource collection data is basically the same as the specific implementation of the storage method for resource collection data described above, and will not be described in detail here.
[0129] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above-mentioned resource collection data storage method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0130] See also Fig. 9 , Fig. 9 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:
[0131] The processor 910 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application.
[0132] The memory 920 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 920 can store an operating system and other applications. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 920, and the processor 910 calls and executes the storage method of resource collection data in the embodiment of this application;
[0133] Input / output interface 930, used to implement information input and output;
[0134] Communication interface 940, used to realize communication interaction between the device and other devices, which can be realized through wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WI FI, Bluetooth, etc.);
[0135] bus 950 , which transmits information between the various components of the device (e.g., processor 910 , memory 920 , input / output interface 930 , and communication interface 940 );
[0136] The processor 910 , the memory 920 , the input / output interface 930 , and the communication interface 940 are connected to each other in communication within the device via a bus 950 .
[0137] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned resource collection data storage method is implemented.
[0138] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0139] The resource collection data storage method and device, electronic device and storage medium provided in the embodiments of the present application greatly reduce the storage space occupied by the resource collection time by converting the resource collection time from character encoding to binary encoding, so as to facilitate the storage of a large amount of resource collection data in the database.
[0140] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0141] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0142] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0143] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0144] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0145] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0146] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0147] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0148] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0149] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0150] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A method for storing resource collection data, characterized in that: The method comprises: Obtain a resource collection request from a target object; the resource collection request includes a target object identifier and a resource collection time of the target object; Acquire the data format of the resource collection time, obtain the collection time character and the time representation format of the collection time character; Bit-encoding the collection time character according to the time representation format to obtain a binary time code of the collection time character; splicing the binary time codes according to the time representation format to obtain a target time code for the resource collection time; Generate resource collection data according to the target object identifier and the target time code; The resource claim data is stored in a preset database.
2. The method according to claim 1, characterized in that The data format of obtaining the resource collection time, obtaining the collection time character and the time representation format of the collection time character, includes: The preset message queue system is screened according to the resource collection time to obtain a target message queue; The resource claim request is stored in the target message queue, and the queue length of the target message queue is obtained; The data format of the resource collection time is acquired according to the queue length, and the collection time character and the time representation format are obtained.
3. The method according to claim 1, characterized in that The bit encoding of the collection time character according to the time representation format to obtain the binary time code of the collection time character includes: Obtaining the number of bits of the bit encoding of the collection time character according to the time representation format; The collection time characters are bit-encoded according to the bit encoding bit number to obtain the binary time code.
4. The method according to claim 1, characterized in that: After storing the resource claiming data in a preset database, the method further includes: Acquire a reference pick-up request for a target object, wherein the reference pick-up request includes the target object identifier and a reference pick-up time of the target object; Query the preset database according to the target object identifier to obtain the target time code; Generate reference pickup data according to the target object identifier, the reference pickup time and the target time code; The reference collection data is stored in the preset database.
5. The method according to claim 4, characterized in that The generating reference pickup data according to the target object identifier, the reference pickup time and the target time code comprises: Bit encoding the reference pickup time to obtain a reference time code of the reference pickup time; comparing the reference time code and the target time code; If the reference time code and the target time code are not the same, the reference collection data is generated according to the target object identifier and the reference time code.
6. The method according to any one of claims 1 to 5, characterized in that: The step of splicing the binary time codes according to the time representation format to obtain the target time code for the resource collection time includes: splicing the binary time codes according to the time representation format to obtain a spliced time code; The splicing time code is filled to obtain the target time code.
7. The method according to any one of claims 1 to 5, characterized in that: After storing the resource claiming data in a preset database, the method further includes: Obtaining the storage duration of storing the resource claim data in a preset database; If the storage duration is greater than the preset duration, reading the resource claiming data from the preset database; The resource claim data is stored in a target database; wherein the target database is different from the preset database.
8. A storage device for resource collection data, characterized in that: The device comprises: A first acquisition module is used to acquire a resource collection request of a target object; the resource collection request includes a target object identifier and a resource collection time of the target object; A second acquisition module is used to acquire the data format of the resource collection time, obtain the collection time character and the time representation format of the collection time character; An encoding module, used for performing bit encoding on the collection time character according to the time representation format to obtain a binary time code of the collection time character; A splicing module, used for splicing the binary time codes according to the time representation format to obtain a target time code for the resource collection time; A generating module, used for generating resource collection data according to the target object identifier and the target time code; The storage module is used to store the resource claim data in a preset database.
9. An electronic device, characterized in that: The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
