Intelligent seat selection method, system and equipment and storage medium
By using the bitmap bitmap data structure in the Redis cache in the theater ticketing system, the problem of slow update speed of seat information in traditional systems under high concurrency is solved, and efficient seat management and data security are achieved.
Patent Information
- Application Number
- CN202411918823.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-05-27
AI Technical Summary
In the case of high concurrency, the seat information is updated slowly, which affects the user's seat selection experience and is difficult to achieve efficient seat management.
The bitmap bitmap data structure in the redis cache stores and reads seat status information, quickly judges and updates the seat status through bit operations, and synchronizes the data to the persistent database and writes it to the disk periodically when necessary.
It realizes efficient seat management, significantly improves system performance and resource utilization efficiency, ensures data consistency and security, and meets the real-time seat query and update requirements under high concurrency.
Smart Images

Figure CN120045558A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of computer technology, and in particular, to an intelligent seat selection method, system, device, and storage medium. Background Art
[0002] In a traditional theater ticketing system, audiences usually go to the ticket office in person or purchase tickets through an online seat selection platform, and then select seats according to their personal preferences. The currently widely used online seat selection platforms allow users to view the theater seat layout diagram through a network interface and select available seats for ticketing. Such platforms usually provide a basic seat view, which includes seat numbers and some view levels (such as VIP area, general area). However, since each show requires an independent seat inventory to record seat selection information, both the prior seat selection platforms and the seat selection systems at the ticket office use databases to establish data tables to store seat information. In the case of a large number of seats and shows, the data increment of this information is huge. If directly reading from the database, the reading efficiency will become lower and lower as the data volume increases. Moreover, even if caching is used, a large amount of memory resources are required, ultimately resulting in a slow seat information update speed, seriously affecting user seat selection, and making it impossible to achieve efficient seat management.
[0003] The above problems need to be solved urgently. Summary of the Invention
[0004] To solve the related technical problems, the present invention provides an intelligent seat selection method, system, device, and storage medium to solve the problems mentioned in the above background art section.
[0005] To achieve the above object, embodiments of the present invention adopt the following technical solutions:
[0006] In a first aspect, embodiments of the present invention provide an intelligent seat selection method, which includes:
[0007] Storing seat status information using the bitmap data structure in the redis cache;
[0008] Receiving the seat information requested by the user;
[0009] Calculating the bitmap value of the corresponding seat according to the seat information requested by the user, and judging whether the seat is available according to the bitmap value;
[0010] If the result of the judgment is yes, updating the bitmap value to indicate that the seat is selected.
[0011] As an optional implementation manner, before receiving the seat information requested by the user, it further includes: setting a seat selection interaction interface, and the user inputs the requested seat information through the seat selection interaction interface.
[0012] As an alternative implementation, the intelligent seat selection method further includes:
[0013] Receiving an automatic seat selection request, executing a seat matching algorithm according to the automatic seat selection request, and obtaining the maximum continuous seats when the number of requested seats is greater than 1.
[0014] As an alternative implementation, the intelligent seat selection method further includes:
[0015] When it is determined that the seat information requested by at least two users is the same, controlling only one user request to succeed through an atomic command and notifying the remaining users that the requested seats are occupied.
[0016] As an alternative implementation, the intelligent seat selection method further includes:
[0017] Presetting a data synchronization period; synchronizing the data in Redis to a persistent database according to the data synchronization period.
[0018] As an alternative implementation, the intelligent seat selection method further includes:
[0019] Regularly or real-time writing seat status data to disk through, but not limited to, RDB (regular snapshot) and AOF (append-only file).
[0020] In a second aspect, an embodiment of the present invention provides an intelligent seat selection system. This system adopts the intelligent seat selection method described in any one of the embodiments of the first aspect above, and includes:
[0021] A seat status information storage module, which is used to store seat status information by using the bitmap data structure in the Redis cache;
[0022] A user request receiving module, which is used to receive the seat information requested by the user;
[0023] A seat status information judgment module, which is used to calculate the bitmap value of the corresponding seat according to the seat information requested by the user, and judge whether the seat is available according to the bitmap value;
[0024] A seat status information update module, which is used to update the bitmap value to indicate that the seat is selected if the result of the judgment is yes.
[0025] As an alternative implementation, the intelligent seat selection system further includes:
[0026] A seat selection module, which is used to allow the user to input the requested seat information through a seat selection interaction interface.
[0027] In a third aspect, an embodiment of the present invention provides an electronic device, which includes a processor and a memory connected to the processor. Among them, program data is stored in the memory, and the processor retrieves the program data stored in the memory to execute the intelligent seat selection method provided in the embodiment of the first aspect above.
[0028] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the intelligent seat selection method provided in the embodiment of the first aspect above.
[0029] The technical solution proposed in the embodiment of the present invention uses the bitmap data structure in the redis cache to store and read seat status information, stores the sequence and status information of the seat arrangement into the bitmap value, and both the storage and reading of data are performed in memory, so the access speed of the data is extremely fast, meeting the needs of real-time seat query and update under high concurrency, realizing efficient seat management, and significantly improving the system performance and resource utilization efficiency; moreover, one bit can store one seat, greatly saving the storage space of seat information. The technical solution proposed in the embodiment of the present invention receives an automatic seat selection request, executes a seat matching algorithm according to the automatic seat selection request, and when the number of requested seats is greater than 1, obtains the maximum continuous seats, improving the utilization rate of the maximum continuous seats. The technical solution proposed in the embodiment of the present invention synchronizes the data in redis to a persistent database according to the data synchronization period, while ensuring the efficient processing of real-time seat updates by redis, preventing the loss of seat status caused by system failures, and ensuring the consistency and security of the data; writes the seat status data to the disk regularly or in real time. When the server restarts or fails, redis automatically restores the seat status data from the disk to ensure that the system quickly returns to the latest state and avoid data loss. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] In order to more clearly illustrate and understand the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for the background technology and the description of the embodiments of the present invention. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained according to the content of the embodiments of the present invention and these drawings.
[0031] Figure 1 It is a schematic flowchart of the intelligent seat selection method provided in Embodiment 1 of the present invention;
[0032] Figure 2 and Figure 3 It is a schematic diagram of the multi-zone structure of seats provided in Embodiment 1 of the present invention;
[0033] Figure 4 Schematic diagram of the hybrid partition structure provided by the first embodiment of the present invention;
[0034] Figure 5 Schematic diagram of the theater seat selection process provided by the first embodiment of the present invention;
[0035] Figure 6 Schematic diagram of the structure of the intelligent seat selection system provided by the second embodiment of the present invention. Detailed implementation manners
[0036] To make the technical problems solved by the present invention, the technical solutions adopted and the achieved technical effects clearer, the technical solutions of the embodiments of the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative efforts fall within the protection scope of the present invention.
[0037] Embodiment 1
[0038] Please refer to Figure 1 as described Figure 1 Schematic diagram of the intelligent seat selection method flow provided by the first embodiment of the present invention. As shown in the figure, the intelligent seat selection method 100 in this embodiment includes the following steps:
[0039] S101. Store seat status information using the bitmap data structure in the redis cache;
[0040] S102. Receive the seat information requested by the user;
[0041] S103. Calculate the bitmap value of the corresponding seat according to the seat information requested by the user, and determine whether the seat is available according to the bitmap value;
[0042] S104. If the result of the judgment is yes, update the bitmap value to indicate that the seat is selected.
[0043] In this embodiment, storing seat status information by using the bitmap data structure in the redis cache includes: according to the seat layout, creating a key in redis for each theater session, and the value type of this key is bitmap. Calculate the offset of each seat in the bitmap as offset according to the seat row number, seat column number and the seat distribution of the theater, and set its position to 0, indicating that the seat is not reserved. If the current seat row number is seatRow, the seat column number is seatCol, the total row number of the theater is totalRow, and the total column number is totalCol, then calculate the offset of the current seat as offset = (seatRow - 1) * totalCol + seatCol, and use the redis bit operation command SETBIT key offset value to set the corresponding seat status information to 0.
[0044] In this embodiment, bitmap is a data structure of string type, and each of its strings can be set to 0 or 1. This embodiment is used to represent whether a seat is occupied or not. Each seat is represented by a bit, which greatly saves storage space. In this embodiment, preferably, the bitmap of redis represents the status of each seat with a bit. For example, the 1st bit represents the 1st seat, the 2nd bit represents the 2nd seat, and so on. If the seat is occupied, the bit value is 1; if it is not occupied, it is 0. In this way, by mapping the seat numbers to bit positions, the status of the entire seating area can be stored in a continuous bitmap. For example, for 1000 seats, only 125 bytes (1000 / 8 bytes) are needed for storage, which greatly reduces the storage space of seat data and makes the storage more efficient.
[0045] Exemplarily, a seat selection interaction interface is set up, and the user inputs the requested seat information through the seat selection interaction interface. In the application, it is not limited to the seat selection interaction interface, and other seat selection interaction methods are also possible.
[0046] In this embodiment, the seat information requested by the user is received; according to the seat information requested by the user, the bitmap value of the corresponding seat is calculated, and whether the seat is available is judged according to the bitmap value, including:
[0047] Based on the seat information in the received user request, determine the seat distribution information of the theater requested by the current user and the seat information that the current user needs to lock. Process the seat information transmitted by the user (such as row number - column number), and calculate the seat offset offset transmitted by the user through the total seat distribution of the current theater. Specifically, convert the seat information requested by the user into the corresponding offset in the bitmap in redis, use the redis operation bitmap bit operation command GETBIT key offset to query the bitmap value of the corresponding seat. If the bitmap value is 0, it means the seat is available, update the bitmap value of this seat to 1 to indicate that the seat is selected, and feedback the corresponding seating result to the user interface for display.
[0048] Exemplarily, the intelligent seat selection method 100 further includes: receiving an automatic seat selection request, executing a seat matching algorithm according to the automatic seat selection request, and obtaining the maximum continuous seats when the number of requested seats is greater than 1.
[0049] In this embodiment, as Figure 2 and Figure 3 shown, according to the storage structure of the bitmap, regard the sequence of seats as M rows and N columns, regarded as points at the position of M0N, so as to construct a matrix.
[0050] For the case where there is no physical isolation for partitions: as Figure 4 shown, regard all partitions as a matrix of m2 * n2, obtain the seat inventory according to the show and initialize the values of the matrix. According to the total number of seats num in the theater and the theater seat distribution map information, traverse all seat information in the order of rows first and columns later in the theater, obtain the row and column information of each seat, and convert it into the corresponding seat offset. According to the obtained offset information of each seat, use the redis command to obtain the seat status of the offset of each seat, use bit operation to judge whether it meets the seating requirements, and save the seats that meet the requirements with the row and column coordinates of the matrix.
[0051] In this embodiment, for the seat matching algorithm, 1. Make a loop judgment on the minimum number of seats that can be seated; 2. In the case where no result is returned in the previous step, according to the maximum number of continuously available seats maxAvailAbleNum, split the number of seats to be occupied into maxAvailAbleNum+(needNum - maxAvailAbleNum), directly occupy maxAvailAbleNum, where when counting maxAvailAbleNum in the previous step, record the corresponding matrix subscript interval; 3. Put the remaining needNum - maxAvailAbleNum into the second iteration and stop when the cumulative occupied number = needNum. Exemplarily, in specific applications, the seat selection process is as Figure 5 shown.
[0052] For the case of physical isolation by partition: 1. Group all seats in a session by partition and process each group cyclically, initializing a matrix of m1*n1; 2. Calculate the maximum continuously available number of seats maxAvailAbleNum for each partition first, and execute the seat matching algorithm according to the relationship between needNum and maxAvailAbleNum; 2-1. If needNum > maxAvailAbleNum for each partition, first execute the seat matching algorithm for the partition with maxAvailAbleNum closest to needNum; after the remaining seats are insufficient in the first round, execute the algorithm for the partition closest to or equal to the remaining seats to occupy seats, and stop after reaching needNum; 2-2. If needNum < maxAvailAbleNum for each partition, directly find a partition with maxAvailAbleNum closest to needNum to occupy seats; 2-3. If needNum is between maxAvailAbleNum for all partitions, find the partition closest to it in the partitions greater than needNum and execute the algorithm to occupy seats; 3. When needNum is 1, directly find a partition, find the first available subscript and return.
[0053] Exemplarily, when it is determined that the seat information requested by at least two users is the same, an atomic command is used to control that only one user request succeeds, and the remaining users are notified that the requested seats have been occupied. In this embodiment, an atomic command means that each command is indivisible during execution, that is, it will not be interrupted by other operations. Therefore, data conflicts can be effectively avoided, ensuring that there are no conflicts in the update of seat status when multiple users select seats simultaneously. The intelligent seat selection scheme proposed in this embodiment realizes the exclusive occupation of seats through the atomicity of redis: when multiple users simultaneously request to select the same seat, an atomic command such as SETBIT is used to control that only one user request succeeds, and the remaining users are notified that the requested seats have been occupied. This embodiment not only ensures the exclusivity of seat selection, but also greatly improves the stability in a high-concurrency environment, effectively avoiding data inconsistency problems caused by seat selection conflicts.
[0054] Exemplarily, the intelligent seat selection method 100 further includes: presetting a data synchronization period; synchronizing the data in redis to a persistent database according to the data synchronization period.
[0055] In this embodiment, a data synchronization period can be preset. The server synchronizes the data in Redis to the persistent database at regular intervals according to the data synchronization period, ensuring data security and reliability. Specifically, according to the preset data synchronization period, the server can perform batch synchronization every few minutes or hours, and batch write the seat status data recorded in Redis into the persistent database. Through the above "periodic synchronization" mechanism, while ensuring the efficient processing of real-time seat updates by Redis, it provides support for data backup, prevents the loss of seat status due to system failures, and ensures data consistency and security.
[0056] Exemplarily, the intelligent seat selection method 100 further includes: writing the seat status data to the disk periodically or in real time through, but not limited to, RDB (regular snapshot) and AOF (append-only file).
[0057] In this embodiment, Redis writes the seat status data to the disk periodically or in real time through two methods: RDB and AOF. When the server restarts or fails, Redis can automatically restore the seat status data from the disk backup file, ensuring that the system quickly resumes to the latest state and avoiding data loss. The automatic backup mechanism proposed in this embodiment reduces the dependence on additional manual backups, improves the efficiency of data persistence, and realizes automatic data backup.
[0058] In this embodiment, the bitmap provides a query and update complexity of O(1). Users can set and obtain the status of a specified seat through the Redis commands SETBIT key offset value and GETBIT key offset respectively. This operation allows the system to maintain fast read and write performance under high concurrency and achieve fast access to intelligent seat selection. For example, when a user queries the seat status, the system can directly obtain the occupancy status of the specified seat through GETBIT without having to traverse the entire structure. In this embodiment, the high performance and persistence characteristics of Redis support fast response under high concurrency, ensuring real-time seat status updates in the system under high load. Since the operations of the bitmap are very lightweight, the Redis server can promptly respond to status changes and avoid delayed data synchronization, which is crucial for seat selection scenarios such as cinemas with high real-time requirements. The high performance characteristics of Redis effectively ensure the real-time and accuracy of seat status in a high-concurrency environment.
[0059] In this embodiment, the bitmap structure is simple and compact, making maintenance and expansion more flexible. For example, for adding or removing seats, only the bit at the corresponding position needs to be increased or decreased, and only the status of the corresponding bit needs to be modified, without affecting other bits. In addition, the bitmap simplifies seat statistics and batch operations. For example, the number of empty seats can be quickly counted through the BITCOUNT command, facilitating subsequent business analysis and optimization. The intelligent seat selection method 100 proposed in this embodiment simplifies the data structure, making the system easier to maintain and expand.
[0060] The intelligent seat selection method 100 proposed in the embodiment of the present invention uses the bitmap data structure in the redis cache to store and read seat status information. The sequence and status information of the seat arrangement are stored in the bitmap value. The storage and reading of data are both performed in memory, and the access speed of the data is extremely fast, meeting the needs of real-time seat query and update under high concurrency, realizing efficient seat management, and significantly improving the system performance and resource utilization efficiency. Moreover, one bit can store one seat, greatly saving the storage space of seat information. The intelligent seat selection method 100 proposed in the embodiment of the present invention receives an automatic seat selection request, executes a seat matching algorithm according to the automatic seat selection request, and obtains the maximum continuous seats when the number of requested seats is greater than 1, improving the utilization rate of the maximum continuous seats. The intelligent seat selection method 100 proposed in the embodiment of the present invention synchronizes the data in redis to the persistent database according to the data synchronization period, preventing the loss of seat status caused by system failures while ensuring the efficient processing of real-time seat updates by redis, ensuring data consistency and security. The seat status data is written to the disk regularly or in real time. When the server restarts or fails, redis automatically restores the seat status data from the disk, ensuring that the system quickly resumes to the latest state and avoiding data loss.
[0061] Embodiment Two
[0062] Please refer to Figure 6 as described Figure 6 This is a schematic structural diagram of the intelligent seat selection system provided in Embodiment Two of the present invention. As shown in the figure, in this embodiment, the intelligent seat selection system 600 adopts the intelligent seat selection method 100 described in Embodiment One above. The system includes:
[0063] A seat status information storage module 601, which is used to store seat status information using the bitmap data structure in the redis cache;
[0064] A user request receiving module 602, which is used to receive the seat information requested by the user;
[0065] A seat status information judgment module 603, configured to calculate a bitmap value of a corresponding seat according to the seat information requested by the user, and judge whether the seat is available according to the bitmap value;
[0066] A seat status information update module 604, configured to, if the judgment result is yes, update the bitmap value to indicate that the seat is selected.
[0067] In this embodiment, storing seat status information by using the bitmap data structure in the redis cache includes: creating a key in the redis for each theater session according to the seat layout, and the value type of the key is bitmap. Calculate the offset offset of each seat in the bitmap according to the seat row number, seat column number and the seat distribution of the theater, and set its position to 0, indicating that the seat is not reserved. If the current seat row number is seatRow, the seat column number is seatCol, the total row number of the theater is totalRow, and the total column number is totalCol, then calculate the offset of the current seat offset = (seatRow - 1) * totalCol + seatCol, and use the redis bit operation command SETBIT key offset value to set the corresponding seat status information to 0.
[0068] In this embodiment, the bitmap is a data structure of string type, and each of its strings can be set to 0 or 1. This embodiment is used to represent whether a seat is occupied or not. Each seat is represented by a bit, which greatly saves storage space. In this embodiment, preferably, the bitmap of redis represents the status of each seat by a bit. For example, the 1st bit represents the 1st seat, the 2nd bit represents the 2nd seat, and so on. If the seat is occupied, the bit value is 1, and if it is not occupied, it is 0. In this way, by mapping the seat numbers to bit positions, the status of the entire seat area can be stored in a continuous bitmap. For example, for 1000 seats, only 125 bytes (1000 / 8 bytes) are required for storage, which greatly reduces the storage space of seat data and makes storage more efficient.
[0069] Exemplarily, the intelligent seat selection system 600 further includes: a seat selection module, configured to enable a user to input requested seat information through a seat selection interaction interface. In applications, it is not limited to the seat selection interaction interface, and it can also be other seat selection interaction methods.
[0070] In this embodiment, the user request receiving module 602 receives the seat information requested by the user; the seat status information judgment module calculates the bitmap value of the corresponding seat according to the seat information requested by the user, and judges whether the seat is available according to the bitmap value, including:
[0071] Based on the seat information requested by the received user, determine the seat distribution information of the theater requested by the current user and the seat information that the current user needs to lock, process the seat information transmitted by the user (such as row number-column number), and calculate the seat offset offset transmitted by the user through the total seat distribution of the current theater. Specifically, convert the seat information requested by the user into the corresponding offset in the bitmap in redis, use the redis operation bitmap bit operation command GETBIT key offset to query the bitmap value of the corresponding seat. If the bitmap value is 0, it means the seat is available, update the bitmap value of this seat to 1 to indicate that the seat is selected, and feedback the corresponding seating result to the user interface for display.
[0072] Exemplarily, the intelligent seat selection system 600 further includes: an automatic seat selection module. The automatic seat selection module is used to send an automatic seat selection request; the user request receiving module 602 receives the automatic seat selection request; the seat status information judgment module 603 executes a seat matching algorithm according to the automatic seat selection request, and when the number of requested seats is greater than 1, obtains the maximum continuous seats.
[0073] In this embodiment, as Figure 2 and Figure 3 shown, according to the storage structure of the bitmap, regard the sequence of seats as M rows and N columns, regarded as points at the position of M0N, so as to construct a matrix.
[0074] For the case where there is no physical isolation for partitions: as Figure 4 shown, regard all partitions as a matrix of m2*n2, obtain the seat inventory according to the show and initialize the values of the matrix. According to the total number of seats num in the theater and the theater seat distribution map information, traverse all seat information in the order of rows first and columns later in the theater, obtain the row and column information of each seat, and convert it into the corresponding seat offset. According to the obtained offset information of each seat, use the redis command to obtain the seat status of the offset of each seat, and use bit operation to judge whether it meets the seating requirements, and save the seats that meet the requirements with the row and column coordinates of the matrix.
[0075] In this embodiment, for the seat matching algorithm: 1. Make a loop judgment on the minimum available seats; 2. In the case where no result is returned in the previous step, according to the maximum continuous available seats maxAvailAbleNum, split the number of seats to be occupied into maxAvailAbleNum+(needNum-maxAvailAbleNum), directly occupy the seats for maxAvailAbleNum, where, when counting maxAvailAbleNum in the previous step, record the corresponding matrix subscript interval; 3. Put the remaining needNum-maxAvailAbleNum into the second step iteration and stop when the cumulative occupied number = needNum. Exemplarily, in a specific application, the seat selection process is as Figure 5 shown.
[0076] For the case of physical isolation of partitions: 1. Group all the seats in a session by partition and process each group in a loop, initializing a matrix of m1*n1; 2. First calculate the maximum continuous available seats maxAvailAbleNum for each partition, and execute the seat matching algorithm according to the relationship between needNum and maxAvailAbleNum; 2-1. If needNum>maxAvailAbleNum for each partition, then preferentially execute the seat matching algorithm for the partition with maxAvailAbleNum closest to needNum; after the remaining seats are insufficient in the first round, execute the algorithm to occupy seats for the partition closest to or equal to the remaining seats and stop after reaching needNum; 2-2. If needNum<maxAvailAbleNum for each partition, then directly find a partition with maxAvailAbleNum closest to needNum to occupy seats; 2-3. If needNum is between maxAvailAbleNum for all partitions, then find the partition closest to needNum in the partitions greater than needNum and execute the algorithm to occupy seats; 3. When needNum is 1, then directly find a partition and return the first available subscript.
[0077] Exemplarily, when it is determined that the seat information requested by at least two users is the same, an atomic command is used to control only one user request to succeed, and the remaining users are notified that the requested seats are occupied. In this embodiment, an atomic command means that each command is indivisible during execution, that is, it will not be interrupted by other operations. Therefore, data conflicts can be effectively avoided, ensuring that there are no conflicts in the update of seat status when multiple users select seats simultaneously. The intelligent seat selection scheme proposed in this embodiment realizes the exclusive occupation of seats through the atomicity of Redis: when multiple users simultaneously request to select the same seat, an atomic command such as SETBIT is used to control only one user request to succeed, and the remaining users are notified that the requested seats are occupied. This embodiment not only ensures the exclusivity of seat selection, but also greatly improves the stability in a high-concurrency environment, effectively avoiding data inconsistency problems caused by seat selection conflicts.
[0078] Exemplarily, the intelligent seat selection system 600 further includes a data synchronization module. The data synchronization module is used to preset a data synchronization period, and according to the data synchronization period, synchronize the data in Redis to a persistent database.
[0079] In this embodiment, a data synchronization period can be preset, and the server synchronizes the data in Redis to the persistent database at regular intervals according to the data synchronization period to ensure data security and reliability. Specifically, the server can perform a batch synchronization every few minutes or hours according to the preset data synchronization period, and batch-write the seat status data recorded in Redis into the persistent database. Through the above "periodic synchronization" mechanism, while ensuring the efficient processing of real-time seat updates by Redis, it provides support for data backup, prevents the loss of seat status due to system failures, and ensures data consistency and security.
[0080] Exemplarily, the intelligent seat selection system 600 further includes a backup module; the backup module writes the seat status data to the disk regularly or in real time through, but not limited to, RDB (periodic snapshot) and AOF (append-only file). In this embodiment, Redis writes the seat status data to the disk regularly or in real time through RDB and AOF. When the server restarts or fails, Redis can automatically restore the seat status data from the disk backup file to ensure that the system quickly resumes to the latest state and avoid data loss. The automatic backup mechanism proposed in this embodiment reduces the dependence on additional manual backups, improves the efficiency of data persistence, and realizes automatic data backup.
[0081] In this embodiment, the bitmap provides O(1) query and update complexity. Users can set and obtain the status of a specified seat through the redis commands SETBIT key offset value and GETBIT key offset respectively. This operation allows the system to maintain fast read and write performance under high concurrency, enabling fast access to intelligent seat selection. For example, when a user queries the seat status, the system can directly obtain the occupancy status of the specified seat through GETBIT without having to traverse the entire structure. In this embodiment, the high performance and persistence characteristics of redis support fast response under high concurrency, ensuring real-time seat status updates in the system under high load. Since the operations of the bitmap are very lightweight, the redis server can respond to status changes in a timely manner, avoiding delayed data synchronization, which is crucial for seat selection scenarios such as cinemas with high real-time requirements. The high performance characteristics of redis effectively ensure the real-time and accuracy of seat status in a high-concurrency environment.
[0082] In this embodiment, the bitmap structure is simple and compact, making maintenance and expansion more flexible. For example, for adding or removing seats, only the bit at the corresponding position needs to be increased or decreased, and only the status of the corresponding bit needs to be modified without affecting other bits. In addition, the bitmap simplifies seat statistics and batch operations. For example, the number of empty seats can be quickly counted through the BITCOUNT command, facilitating subsequent business analysis and optimization. The intelligent seat selection system 600 proposed in this embodiment simplifies the data structure, making the system easier to maintain and expand.
[0083] The intelligent seat selection system 600 proposed in the embodiments of the present invention stores and reads seat status information using the bitmap data structure in the redis cache, stores the sequence and status information of the seat arrangement into the bitmap value, and both the storage and reading of data are performed in memory, with extremely fast data access speed, meeting the needs of real-time seat query and update under high concurrency, achieving efficient seat management, and significantly improving the system performance and resource utilization efficiency; moreover, one bit can store one seat, greatly saving the storage space of seat information. The intelligent seat selection system 600 proposed in the embodiments of the present invention receives an automatic seat selection request, executes a seat matching algorithm according to the automatic seat selection request, and when the number of requested seats is greater than 1, obtains the maximum continuous seats, improving the utilization rate of the maximum continuous seats. The intelligent seat selection system 600 proposed in the embodiments of the present invention synchronizes the data in redis to a persistent database according to the data synchronization period, while ensuring the efficient processing of real-time seat updates by redis, preventing the loss of seat status caused by system failures, and ensuring data consistency and security; writes the seat status data to the disk regularly or in real time, and when the server restarts or fails, redis automatically restores the seat status data from the disk, ensuring that the system quickly resumes to the latest state and avoiding data loss.
[0084] Embodiment III
[0085] This embodiment provides an electronic device, which includes a processor and a memory connected to the processor. Among them, program data is stored in the memory, and the processor retrieves the program data stored in the memory to execute the intelligent seat selection method 100 provided in Embodiment I above.
[0086] Embodiment IV
[0087] The embodiments of the present invention provide a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, they are used to implement the intelligent seat selection method 100 provided in Embodiment I above.
[0088] It should be noted that the above-readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium accessible by a general-purpose or special-purpose computer.
[0089] Note that the above is only a preferred embodiment of the present invention and the technical principles applied. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, re-adjustments and substitutions can be made by those skilled in the art without departing from the protection scope of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments. Without departing from the concept of the present invention, more other equivalent embodiments can be included, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. An intelligent seat selection method, characterized in that: include: Use the bitmap data structure in the redis cache to store seat status information; Receiving seat information requested by a user; Calculate the bitmap value of the corresponding seat according to the seat information requested by the user, and determine whether the seat is available according to the bitmap value; If the result of the judgment is yes, the bitmap value is updated to indicate that the seat is selected.
2. The intelligent seat selection method according to claim 1, characterized in that: The step of receiving the seat information requested by the user also includes: setting a seat selection interaction interface, and the user inputs the requested seat information through the seat selection interaction interface.
3. The intelligent seat selection method according to claim 1, characterized in that: Also includes: An automatic seat selection request is received, and a seat matching algorithm is executed according to the automatic seat selection request, and when the number of requested seats is greater than 1, the maximum number of consecutive seats is obtained.
4. The intelligent seat selection method according to claim 1, characterized in that: Also includes: When it is determined that the seat information requested by at least two users is the same, only one user's request is successful through atomic command control, and the remaining users are notified that the seats requested are occupied.
5. The intelligent seat selection method according to claim 1, characterized in that: Also includes: Preset data synchronization cycle; According to the data synchronization cycle, the data in redis is synchronized to the persistent database.
6. The intelligent seat selection method according to any one of claims 1 to 5, characterized in that: Also includes: The seat status data is written to the disk periodically or in real time by means of, but not limited to, periodic snapshots and append logs.
7. An intelligent seat selection system, characterized in that: The system adopts the intelligent seat selection method according to claim 1, comprising: The seat status information storage module is used to store the seat status information using the bitmap data structure in the redis cache; A user request receiving module, used for receiving seat information requested by a user; A seat status information determination module, used to calculate the bitmap value of the corresponding seat according to the seat information requested by the user, and determine whether the seat is available according to the bitmap value; The seat status information updating module is used to update the bitmap value if the result of the judgment is yes, so as to indicate that the seat is selected.
8. The intelligent seat selection system according to claim 7, characterized in that: Also includes: The seat selection module is used for allowing the user to input the requested seat information through the seat selection interactive interface.
9. An electronic device, comprising a processor and a memory connected to the processor, wherein: The memory stores program data, and the processor calls the program data stored in the memory to execute the intelligent seat selection method as described in claim 1.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the intelligent seat selection method as claimed in claim 1.