WO2019096134A1 - Information storage method and apparatus, storage medium, and electronic device - Google Patents

Information storage method and apparatus, storage medium, and electronic device Download PDF

Info

Publication number
WO2019096134A1
WO2019096134A1 PCT/CN2018/115268 CN2018115268W WO2019096134A1 WO 2019096134 A1 WO2019096134 A1 WO 2019096134A1 CN 2018115268 W CN2018115268 W CN 2018115268W WO 2019096134 A1 WO2019096134 A1 WO 2019096134A1
Authority
WO
WIPO (PCT)
Prior art keywords
queue
application
target
identifier
switching information
Prior art date
Application number
PCT/CN2018/115268
Other languages
French (fr)
Chinese (zh)
Inventor
梁昆
Original Assignee
Oppo广东移动通信有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Oppo广东移动通信有限公司 filed Critical Oppo广东移动通信有限公司
Publication of WO2019096134A1 publication Critical patent/WO2019096134A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/461Saving or restoring of program or task context
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3438Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment monitoring of user actions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3466Performance evaluation by tracing or monitoring
    • G06F11/3476Data logging
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0608Saving storage space on storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data

Definitions

  • the present application relates to the field of computer technologies, and in particular, to an information storage method, apparatus, storage medium, and electronic device.
  • the embodiment of the present invention provides an information storage method, device, storage medium, and electronic device, which can reduce memory usage during information storage and improve storage effect.
  • the embodiment of the present application provides an information storage method, which is applied to a first electronic device, and includes:
  • the application queue library is updated according to the updated first target queue.
  • the embodiment of the present application further provides an information storage device, which is applied to the first electronic device, and includes:
  • An acquiring module configured to acquire application information to be stored, where the application information includes target application identifier and target switching information;
  • a determining module configured to determine, according to the target application identifier, a first target queue from the stored application queue library, where the application queue library includes at least one application queue, and each application queue includes at least one switching information;
  • a first update module configured to update the first target queue according to the target switching information, to store the application information in the application queue library
  • a second update module configured to update the application queue library according to the updated first target queue.
  • the embodiment of the present application further provides a storage medium, where the storage medium stores a plurality of instructions, and the instructions are adapted to be loaded by a processor to execute any of the foregoing information storage methods.
  • the embodiment of the present application further provides an electronic device, including a processor and a memory, the processor is electrically connected to the memory, the memory is used to store instructions and data, and the processor is used in any one of the foregoing The steps in the information storage method described.
  • FIG. 1 is a schematic flowchart diagram of an information storage method according to an embodiment of the present application.
  • FIG. 2 is another schematic flowchart of an information storage method according to an embodiment of the present application.
  • FIG. 3 is a schematic diagram of a hashmap provided by an embodiment of the present application.
  • FIG. 4 is a schematic diagram of an information storage process provided by an embodiment of the present application.
  • FIG. 5 is a schematic structural diagram of an information storage device according to an embodiment of the present disclosure.
  • FIG. 6 is a schematic structural diagram of a second update module according to an embodiment of the present application.
  • FIG. 7 is another schematic structural diagram of an information storage device according to an embodiment of the present disclosure.
  • FIG. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
  • the embodiment of the present application provides an information storage method, device, storage medium, and electronic device.
  • An information storage method is applied to the first electronic device, including: acquiring application information to be stored, the application information including target application identifier and target switching information; determining, according to the target application identifier, the first from the stored application queue library a target queue, the application queue library includes at least one application queue, each application queue includes at least one piece of switching information; and the first target queue is updated according to the target switching information to store the application information in the application queue library; The updated first target queue updates the application queue library.
  • the application queue library further includes at least one application identifier, and each application identifier corresponds to one application queue, and the determining, according to the target application identifier, the first target queue from the stored application queue library, including:
  • the application queue corresponding to the successfully matched application identifier is used as the first target queue
  • the target application identifier is stored in the application queue library, and an empty application queue corresponding to the target application identifier is created as the first target queue.
  • the updating, by the target switching information, the first target queue includes:
  • the number of switching information in the first target queue is counted as the first quantity
  • the updating the application queue library according to the updated first target queue includes:
  • the sorted queue library is updated according to the total number.
  • the updating the sorted queue library according to the total quantity comprises:
  • the information storage method further includes:
  • next application queue in the sorted queue library is used as the queue to be updated, and the difference is used as the total number, and the operation is performed to obtain the second quantity corresponding to the queue to be updated until all The application queue is updated.
  • the information storage method further includes:
  • the switching information in the corresponding application queue is stored in the second electronic device according to the encrypted identifier.
  • the acquiring the synchronous storage instruction includes:
  • the information storage method further includes:
  • the specific process of the information storage method can be as follows:
  • the application identifier (or target application identifier) is a unique identifier of the application, which may be an application name.
  • the switching information (or the target switching information) mainly refers to related information when the application switches to the foreground, such as the switching time, the last foreground application that is switched, and the like.
  • the application queue library is used to store switching information of all applications that have been switched to the foreground in the historical period, and each switching information is stored in the corresponding application queue in the order of switching time, and the application queue may be It is a FIFO (First Input First Output) queue, which is a FIFO data structure, which can only sequentially write switching information and sequentially read switching information.
  • FIFO First Input First Output
  • the application queue library further includes at least one application identifier, and each application identifier corresponds to one application queue.
  • the foregoing step 102 may specifically include:
  • the application queue corresponding to the successfully matched application identifier is used as the first target queue
  • the target application identifier is stored in the application queue library, and an empty application queue corresponding to the target application identifier is created as the first target queue.
  • the application queue and the application identifier stored in the application queue library are stored in association.
  • the application identifier may be used as a key, and the application queue is associated with the value of the key.
  • the electronic device can establish an application queue for each application in advance, or can establish a corresponding application queue when the application is first started. If the application queue is created when the application is started for the first time, if there is no application queue of the current foreground application in the application queue, an empty first-in first-out queue can be established according to the application identifier of the current foreground application, as the application queue of the current foreground application.
  • the foregoing step 103 may specifically include:
  • the number of switching information in the first target queue is counted as the first quantity
  • the new switching information may be stored at the end of the corresponding application queue.
  • the first preset threshold may be determined according to the actual memory size. The larger the actual memory, the larger the first preset threshold may be. For example, the first preset threshold may be 100.
  • the preset number can be an artificially set value, such as 5. Generally, since the frequency of high frequency application (referred to as high frequency application) is switched to the foreground more frequently, the switching information stored in the corresponding application queue should also be more (that is, the queue length is longer), in order to avoid high frequency application.
  • first preset threshold the maximum length of each application queue
  • the storage time can be the longest ( That is, single or partial switching information that is listed in front of the application queue is deleted.
  • the foregoing step 104 may specifically include:
  • the sorted queue library is updated according to the total number.
  • the data amount may be controlled within a certain scale, that is, each time a new switching information is stored, It is necessary to detect the total amount of switching information in the application queue library, and according to the total amount, it is determined that data deletion is not required.
  • the foregoing step of “updating the sorted queue library according to the total quantity” may specifically include:
  • the previous target quantity bar switching information in the queue to be updated is deleted to update the to-be-updated queue.
  • the second preset threshold and the preset ratio may be manually set.
  • the second preset threshold may be 1000, and the preset ratio may be 10%.
  • the switching information of the application may be sequentially deleted according to the frequency of use from the highest to the lowest.
  • the queue after the sorting is usually selected. The first application queue in the middle.
  • the information storage method may further include:
  • next application queue in the sorted queue library is used as the queue to be updated, and the difference is taken as the total quantity, and the operation of obtaining the second quantity corresponding to the queue to be updated is performed until all application queues are updated. .
  • the third preset threshold may be an optimal storage amount manually set, such as 800. After the single application queue is deleted, the total amount of switching information in the application queue library changes. If the total amount of detection exceeds the optimal storage amount, the next application queue needs to be selected for deletion. Decrease until the total amount is less than or equal to the optimal storage amount.
  • the general electronic device since the general electronic device has a power-down protection strategy, that is, the data stored in the system memory is automatically cleared in the case of power failure, in order to avoid data loss stored in the application queue library after the power failure, it may be periodically Synchronizing the information to the external storage device, that is, after the above step 104, the information storage method may further include:
  • the switching information in the corresponding application queue is stored in the second electronic device according to the encrypted identifier.
  • the synchronous storage instruction may be automatically generated after the shutdown or the specified time is reached.
  • the electronic device may set a timer, and the timer may be shut down at a certain time (such as one hour) or received.
  • the information triggers the generation of the synchronous store instruction.
  • the encryption method may be determined according to actual needs, such as AES (Advanced Encryption Standard), which is a symmetric encryption algorithm, that is, encrypting and decrypting data using the same key.
  • AES Advanced Encryption Standard
  • the second electronic device mainly refers to an external storage device, such as a storage server or a hard disk.
  • the application identifier may be encrypted in the synchronous storage process, of course, due to the first in first out.
  • the queue has a certain data structure.
  • the encryption identifier and the switching information can be stored only in the external storage device. Specifically, the electronic device can write the encrypted identifier to the external storage device and then write it back. The car is divided into rows, and then written to the switching information in the corresponding application queue. After writing, the carriage return is also written as the line division, and then the next encryption identifier and its corresponding switching information are written, until all the encryption identifiers and switching are performed. The information has been written.
  • the electronic device can automatically synchronize the data in the external storage storage device into the memory after booting, so as to be subsequently queried and used, that is, After the switching information in the corresponding application queue is stored in the second electronic device according to the encrypted identifier, the information storage method may further include:
  • the application queue library is established according to the application identifier and the corresponding switching information.
  • the same key can be used to decrypt the encrypted identifier, and the application identifier is restored, and then an empty first in first out queue corresponding to the application identifier can be established first, and the empty first ingress is created.
  • the switching information corresponding to the encrypted identifier is sequentially written in the first-out queue, thereby restoring the application queue.
  • the information storage method provided in this embodiment is applied to the first electronic device, and the application information includes the target application identifier and the target switching information, and the target application identifier is stored according to the target application identifier.
  • the application information is stored in the library, and the application queue library is updated according to the updated first target queue, so that in the storage process of the application information, not only the system memory consumption can be reduced, but also the data is comprehensively ensured. Sex, simple method, good storage effect.
  • the information storage device is specifically integrated into the first electronic device as an example for detailed description.
  • an information storage method may be as follows:
  • the first electronic device acquires application information to be stored, where the application information includes a target application identifier and target switching information.
  • the application running in the foreground can be monitored in real time.
  • the application identifier of the changed running application, the application identifier of the running application before the change, and the changed time are used as the application information to be stored.
  • the first electronic device matches the target application identifier with the application identifier in the stored application queue library. If the matching is successful, the application queue corresponding to the successfully matched application identifier is used as the first target queue, and the matching fails. And storing the target application identifier in the application queue library, and creating an empty application queue corresponding to the target application identifier, as the first target queue.
  • the switch information corresponding to the App can be established in the electronic device through a hashmap, where the key is the app name and the value is a first-in, first-out FiFo. (first in, first out) queue, each FiFo queue corresponds to the switching information of the corresponding app.
  • the application identifier stored in the application queue library may include ⁇ App1, App2...Appx ⁇ , and the target application identifier may be Appi.
  • the hashmap may be queried according to i, if i ⁇ (1, 2...x), then If the match is successful, the matching application queue is the application queue corresponding to Appi. If the match fails, you need to create a FiFo queue corresponding to Appi.
  • the first electronic device stores the target switching information at the tail of the first target queue, and when the target switching information is successfully added, the number of the switching information in the first target queue is counted as the first quantity.
  • the first electronic device determines whether the first quantity is greater than a first preset threshold, and if yes, deleting the preset number of switching information in the first target queue, if not, directly Perform the following step 205.
  • the first preset threshold (QueueMax) may be 100, the preset number of entries may be 1, and the application queue corresponding to Appi is Queuei, and the Queuei may include Ni strip switching information, such as Appi_1, Appi_2, ... Appi_Ni, When the switching information stored in the FIFO queue corresponding to Appi exceeds 100, that is, Ni>100, the switching information Appi_1 needs to be deleted.
  • the first electronic device collects the number of switching information in each application queue as the second quantity, and sorts the application queues in the application queue library according to the second quantity in descending order, and obtains the sorted queue.
  • the library after which the total quantity is calculated based on the second quantity.
  • the application queue library includes X application queues of ⁇ Queue1, Queue2...QueueX ⁇ , and the second number of switching information in each application queue may be ⁇ N1, N2... NX ⁇ , then The second number of values corresponding to each application queue sorts them.
  • the first electronic device determines whether the total quantity is greater than a second preset threshold. If yes, performing the following step 207. If not, performing the following step 210.
  • the first electronic device selects the top-ranked application queue in the sorted queue library as the queue to be updated, and obtains the second quantity corresponding to the queue to be updated.
  • the first electronic device determines the target quantity according to the preset ratio and the second quantity corresponding to the to-be-updated queue, and deletes the previous target quantity quantity switching information in the to-be-updated queue to update the to-be-updated queue.
  • the second preset threshold may be 1000, and the preset ratio may be 10%.
  • the first electronic device calculates a difference between the current total quantity and the target quantity, and determines whether the difference is less than or equal to a third preset threshold.
  • the second preset threshold is greater than a third preset threshold. Then, the next application queue in the sorted queue library is used as the queue to be updated, and the difference is taken as the total number, and the above step 208 is performed, and if so, the following step 210 can be performed.
  • the first electronic device acquires a synchronous storage instruction, and acquires an application identifier in the application queue library according to the synchronous storage instruction.
  • the first electronic device may set a timer, which may trigger the generation of the synchronous storage instruction every hour.
  • the synchronous storage instruction may be automatically generated when the power is turned off.
  • the first electronic device encrypts the application identifier, obtains an encrypted identifier, and stores the switching information in the corresponding application queue in the second electronic device according to the encrypted identifier.
  • ⁇ App1, App2...Appx ⁇ can be encrypted by the AES encryption algorithm to obtain an encrypted identifier, and after the encrypted identifier is written to the external storage device, the carriage return is written as a line division, and then the corresponding application is sequentially written.
  • the switching information in the queue is also written to the carriage return as a line division after writing, and then the next encryption identifier and its corresponding switching information are written until all the encryption identifiers and switching information are written.
  • the first electronic device obtains a booting instruction, and obtains an encrypted identifier and a switching information corresponding to the encrypted identifier from the second electronic device according to the booting instruction.
  • the first electronic device decrypts the encrypted identifier, obtains the application identifier, and establishes the application queue library according to the application identifier and the corresponding switching information.
  • the first electronic device can actively obtain the stored content from the external storage device when the device is powered on, and then restore the hashmap through decryption and data structure reconstruction.
  • the information storage method provided in this embodiment wherein the first electronic device can acquire the application information to be stored, the application information includes the target application identifier and the target switching information, and the target application identifier and the stored application queue are The application identifier in the library is matched. If the matching is successful, the application queue corresponding to the successfully matched application identifier is used as the first target queue. If the matching fails, the target application identifier is stored in the application queue library, and a An empty application queue corresponding to the target application identifier is used as the first target queue, and then the target switching information is stored at the tail of the first target queue, and when the target switching information is successfully added, the first target queue is counted. The number of the information to be switched is the first quantity.
  • the first quantity is greater than the first preset threshold. If yes, the preset number of the last number of the first target queue is deleted. If not, the number of switching information in each application queue is counted as the second quantity, and according to the second Sorting the application queues in the application queue library from the largest to the smallest, obtaining the sorted queue library, and then calculating the total quantity according to the second quantity, and then determining whether the total quantity is greater than a second preset threshold, if Then, the application queue of the highest ranked queue in the queued queue is selected as the queue to be updated, and the second quantity corresponding to the queue to be updated is obtained, and then, according to the preset ratio and the second corresponding to the queue to be updated The quantity determines the target quantity, and deletes the previous target quantity bar switching information in the queue to be updated to update the to-be-updated queue, and then calculates the current difference between the total quantity and the target quantity, and determines whether the difference is The second preset threshold is greater than or equal to the
  • the next application queue in the sorted queue library is used as the queue to be updated, and the difference is taken as the total number. And returning to perform an operation of determining whether the total quantity is greater than a second preset threshold, so that not only the system memory usage can be reduced in the storage process of the application information, The data can be comprehensively ensured, the method is simple, and the storage effect is good.
  • the first electronic device can acquire the synchronous storage instruction, and obtain the application identifier in the application queue library according to the synchronous storage instruction, and then apply the application.
  • the identifier is encrypted, and the encrypted identifier is obtained, and the switching information in the corresponding application queue is stored in the second electronic device according to the encrypted identifier, so that the data backup operation can be completed well, and the power-down protection strategy is avoided.
  • the first electronic device can obtain the power-on command, and obtain the encrypted identifier and the switching information corresponding to the encrypted identifier from the second electronic device according to the power-on command, and then perform the encrypted identifier. Decrypting, obtaining the application identifier, and establishing the application queue library according to the application identifier and the corresponding switching information, so that the lost data can be effectively restored after the power is cut off, and the reliability is high.
  • an information storage device which may be implemented as an independent entity or integrated in an electronic device, such as a terminal.
  • the terminal can include a mobile phone, a tablet computer, a personal computer, and the like.
  • the embodiment of the present application provides an information storage device, which is applied to a first electronic device, and includes:
  • An acquiring module configured to acquire application information to be stored, where the application information includes target application identifier and target switching information;
  • a determining module configured to determine, according to the target application identifier, a first target queue from the stored application queue library, where the application queue library includes at least one application queue, and each application queue includes at least one switching information;
  • a first update module configured to update the first target queue according to the target switching information, to store the application information in the application queue library
  • a second update module configured to update the application queue library according to the updated first target queue.
  • the application queue library further includes at least one application identifier, and each application identifier corresponds to one application queue, and the determining module is specifically configured to:
  • a matching submodule configured to match the target application identifier with the application identifier
  • the application queue corresponding to the successfully matched application identifier is used as the first target queue
  • the target application identifier is stored in the application queue library, and an empty application queue corresponding to the target application identifier is created as the first target queue.
  • the first update module is specifically configured to:
  • the number of switching information in the first target queue is counted as the first quantity
  • the second update module specifically includes:
  • a statistics sub-module configured to count the number of switching information in each application queue as a second quantity
  • a sorting sub-module configured to sort the application queues in the application queue library according to the second quantity from large to small, obtain a sorted queue library, and calculate a total quantity according to the second quantity;
  • An update submodule is configured to update the sorted queue library according to the total number.
  • update submodule is specifically configured to:
  • the update submodule is further configured to:
  • next application queue in the sorted queue library is used as the queue to be updated, and the difference is used as the total number, and the operation is performed to obtain the second quantity corresponding to the queue to be updated until all The application queue is updated.
  • the information storage device further includes a synchronization module, configured to:
  • the switching information in the corresponding application queue is stored in the second electronic device according to the encrypted identifier.
  • synchronization module is specifically configured to:
  • the information storage device further includes a second acquiring module, configured to:
  • FIG. 5 specifically describes an information storage device provided by an embodiment of the present application, which is applied to a first electronic device, which may include: a first obtaining module 10, a determining module 20, a first updating module 30, and a second update.
  • Module 40 wherein:
  • the first obtaining module 10 is configured to acquire application information to be stored, where the application information includes a target application identifier and target switching information.
  • the application identifier (or target application identifier) is a unique identifier of the application, which may be an application name.
  • the switching information (or the target switching information) mainly refers to related information when the application switches to the foreground, such as the switching time, the last foreground application that is switched, and the like.
  • a determining module configured to determine, according to the target application identifier, a first target queue from the stored application queue library, where the application queue library includes at least one application queue, and each application queue includes at least one switching information.
  • the application queue library is used to store switching information of all applications that have been switched to the foreground in the historical period, and each switching information is stored in the corresponding application queue in the order of switching time, and the application queue may be It is a FIFO (First Input First Output) queue, which is a FIFO data structure, which can only sequentially write switching information and sequentially read switching information.
  • FIFO First Input First Output
  • the application queue library further includes at least one application identifier, and each application identifier corresponds to one application queue, and the determining module is specifically configured to:
  • a matching submodule configured to match the target application identifier with the application identifier
  • the application queue corresponding to the successfully matched application identifier is used as the first target queue
  • the target application identifier is stored in the application queue library, and an empty application queue corresponding to the target application identifier is created as the first target queue.
  • the application queue and the application identifier stored in the application queue library are stored in association.
  • the application identifier may be used as a key, and the application queue is associated with the value of the key.
  • the electronic device can establish an application queue for each application in advance, or can establish a corresponding application queue when the application is first started. If the application queue is created when the application is started for the first time, if there is no application queue of the current foreground application in the application queue, an empty first-in first-out queue can be established according to the application identifier of the current foreground application, as the application queue of the current foreground application.
  • the first update module 30 is configured to update the first target queue according to the target switching information to store the application information in the application queue library.
  • the first update module 30 can be specifically configured to:
  • the number of switching information in the first target queue is counted as the first quantity
  • the new switching information may be stored at the end of the corresponding application queue.
  • the first preset threshold may be determined according to the actual memory size. The larger the actual memory, the larger the first preset threshold may be. For example, the first preset threshold may be 100.
  • the preset number can be an artificially set value, such as 5. Generally, since the frequency of high frequency application (referred to as high frequency application) is switched to the foreground more frequently, the switching information stored in the corresponding application queue should also be more (that is, the queue length is longer), in order to avoid high frequency application.
  • first preset threshold the maximum length of each application queue
  • the storage time can be the longest ( That is, single or partial switching information that is listed in front of the application queue is deleted.
  • the second update module 40 is configured to update the application queue library according to the updated first target queue.
  • the second update module 40 may specifically include a statistics submodule 41, a sorting submodule 42, and an update submodule 43, where:
  • the statistics sub-module 41 is configured to count the number of switching information in each application queue as the second quantity
  • the sorting sub-module 42 is configured to sort the application queues in the application queue library according to the second quantity from the largest to the smallest, obtain the sorted queue library, and calculate the total quantity according to the second quantity;
  • the update sub-module 43 is configured to update the sorted queue library according to the total number.
  • the data amount may be controlled within a certain scale, that is, each time a new switching information is stored, It is necessary to detect the total amount of switching information in the application queue library, and according to the total amount, it is determined that data deletion is not required.
  • update submodule 43 can be specifically used to:
  • the previous target quantity bar switching information in the queue to be updated is deleted to update the to-be-updated queue.
  • the second preset threshold and the preset ratio may be manually set.
  • the second preset threshold may be 1000, and the preset ratio may be 10%.
  • the switching information of the application may be sequentially deleted according to the frequency of use from the highest to the lowest.
  • the queue after the sorting is usually selected. The first application queue in the middle.
  • the update sub-module 43 can also be used to:
  • next application queue in the sorted queue library is used as the queue to be updated, and the difference is taken as the total quantity, and the operation of obtaining the second quantity corresponding to the queue to be updated is performed until all application queues are updated. .
  • the third preset threshold may be an optimal storage amount manually set, such as 800. After the single application queue is deleted, the total amount of switching information in the application queue library changes. If the total amount of detection exceeds the optimal storage amount, the next application queue needs to be selected for deletion. Decrease until the total amount is less than or equal to the optimal storage amount.
  • the general electronic device since the general electronic device has a power-down protection strategy, that is, the data stored in the system memory is automatically cleared in the case of power failure, in order to avoid data loss stored in the application queue library after the power failure, it may be periodically Synchronizing it to an external storage device, that is, referring to FIG. 7, the information storage device may further include a synchronization module 50 for:
  • the second update module 40 updates the application queue library according to the updated first target queue, acquiring a synchronous storage instruction
  • the switching information in the corresponding application queue is stored in the second electronic device according to the encrypted identifier.
  • the synchronous storage instruction may be automatically generated after the shutdown or the specified time is reached.
  • the electronic device may set a timer, and the timer may be shut down at a certain time (such as one hour) or received.
  • the information triggers the generation of the synchronous store instruction.
  • the encryption method may be determined according to actual needs, such as AES (Advanced Encryption Standard), which is a symmetric encryption algorithm, that is, encrypting and decrypting data using the same key.
  • AES Advanced Encryption Standard
  • the second electronic device mainly refers to an external storage device, such as a storage server or a hard disk.
  • the application identifier may be encrypted in the synchronous storage process, of course, due to the first in first out.
  • the queue has a certain data structure.
  • the encryption identifier and the switching information can be stored only in the external storage device. Specifically, the electronic device can write the encrypted identifier to the external storage device and then write it back. The car is divided into rows, and then written to the switching information in the corresponding application queue. After writing, the carriage return is also written as the line division, and then the next encryption identifier and its corresponding switching information are written, until all the encryption identifiers and switching are performed. The information has been written.
  • the information storage device may further include a second obtaining module 60, configured to:
  • the synchronization module 50 After the synchronization module 50 stores the switching information in the corresponding application queue in the second electronic device according to the encryption identifier, acquiring a booting instruction;
  • the application queue library is established according to the application identifier and the corresponding switching information.
  • the same key can be used to decrypt the encrypted identifier, and the application identifier is restored, and then an empty first in first out queue corresponding to the application identifier can be established first, and the empty first ingress is created.
  • the switching information corresponding to the encrypted identifier is sequentially written in the first-out queue, thereby restoring the application queue.
  • the foregoing units may be implemented as a separate entity, or may be implemented in any combination, and may be implemented as the same or a plurality of entities.
  • the foregoing method embodiments and details are not described herein.
  • the information storage device is applied to the first electronic device, and the application information to be stored is acquired by the first acquiring module 10, the application information includes the target application identifier and the target switching information, and the determining module 20 is configured according to the The target application identifier determines a first target queue from the stored application queue library, the application queue library includes at least one application queue, each application queue includes at least one piece of switching information, and the first update module 30 switches the information according to the target A target queue is updated to store the application information in the application queue library, and the second update module 40 updates the application queue library according to the updated first target queue, so that not only the application information storage process but also Reducing the system memory footprint can also ensure the comprehensiveness of the data, the method is simple, and the storage effect is good.
  • the embodiment of the present application further provides an electronic device, which may be a device such as a smart phone or a tablet computer.
  • the electronic device 900 includes a processor 901, a memory 902, a display screen 903, and a control circuit 904.
  • the processor 901 is electrically connected to the memory 902, the display screen 903, and the control circuit 904, respectively.
  • the processor 901 is a control center of the electronic device 900, and connects various parts of the entire electronic device using various interfaces and lines, executes the electronic by running or loading an application stored in the memory 902, and calling data stored in the memory 902.
  • the various functions and processing data of the device enable overall monitoring of the electronic device.
  • the processor 901 in the electronic device 900 loads the instructions corresponding to the process of one or more applications into the memory 902 according to the following steps, and is stored in the memory 902 by the processor 901.
  • the application thus implementing various functions:
  • the application queue library is updated according to the updated first target queue.
  • the application queue library further includes at least one application identifier, and each application identifier corresponds to one application queue, and the determining, according to the target application identifier, the first target queue from the stored application queue library, including:
  • the application queue corresponding to the successfully matched application identifier is used as the first target queue
  • the target application identifier is stored in the application queue library, and an empty application queue corresponding to the target application identifier is created as the first target queue.
  • the updating, by the target switching information, the first target queue includes:
  • the number of switching information in the first target queue is counted as the first quantity
  • the updating the application queue library according to the updated first target queue includes:
  • the sorted queue library is updated according to the total number.
  • the updating the sorted queue library according to the total quantity comprises:
  • the information storage method further includes:
  • next application queue in the sorted queue library is used as the queue to be updated, and the difference is used as the total number, and the operation is performed to obtain the second quantity corresponding to the queue to be updated until all The application queue is updated.
  • the information storage method further includes:
  • the switching information in the corresponding application queue is stored in the second electronic device according to the encrypted identifier.
  • the acquiring the synchronous storage instruction includes:
  • the information storage method further includes:
  • Memory 902 can be used to store applications and data.
  • the application stored in the memory 902 contains instructions executable in the processor.
  • Applications can form various functional modules.
  • the processor 901 executes various functional applications and data processing by running an application stored in the memory 902.
  • the display screen 903 can be used to display information entered by the user or information provided to the user as well as various graphical user interfaces of the terminal, which can be composed of images, text, icons, video, and any combination thereof.
  • the control circuit 904 is electrically connected to the display screen 903 for controlling the display screen 903 to display information.
  • the electronic device 900 further includes a radio frequency circuit 905, an input unit 906, an audio circuit 907, a sensor 908, and a power source 909.
  • the processor 901 is electrically connected to the radio frequency circuit 905, the input unit 906, the audio circuit 907, the sensor 908, and the power source 909, respectively.
  • the radio frequency circuit 905 is used for transmitting and receiving radio frequency signals to establish wireless communication with network devices or other electronic devices through wireless communication, and to transmit and receive signals with network devices or other electronic devices.
  • the input unit 906 can be configured to receive input digits, character information, or user characteristic information (eg, fingerprints), and to generate keyboard, mouse, joystick, optical, or trackball signal inputs related to user settings and function controls.
  • the input unit 906 can include a fingerprint identification module.
  • the audio circuit 907 can provide an audio interface between the user and the terminal through a speaker and a microphone.
  • Electronic device 900 may also include at least one type of sensor 908, such as a light sensor, motion sensor, and other sensors.
  • the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel according to the brightness of the ambient light, and the proximity sensor may close the display panel and/or the backlight when the terminal moves to the ear.
  • the gravity acceleration sensor can detect the magnitude of acceleration in all directions (usually three axes). When it is stationary, it can detect the magnitude and direction of gravity.
  • the terminal can also be configured with gyroscopes, barometers, hygrometers, thermometers, infrared sensors and other sensors, no longer Narration.
  • Power source 909 is used to power various components of electronic device 900.
  • the power supply 909 can be logically coupled to the processor 901 through a power management system to enable functions such as managing charging, discharging, and power management through the power management system.
  • the electronic device 900 may further include a camera, a Bluetooth module, and the like, and details are not described herein again.
  • an embodiment of the present invention provides a storage medium in which a plurality of instructions are stored, which can be loaded by a processor to perform the steps in any of the information storage methods provided by the embodiments of the present invention.
  • the storage medium may include: a read only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
  • ROM read only memory
  • RAM random access memory
  • magnetic disk a magnetic disk or an optical disk.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Human Computer Interaction (AREA)
  • Software Systems (AREA)
  • Stored Programmes (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

An information storage method and apparatus, a storage medium, and an electronic device. The method is applied to a first electronic device, and comprises: obtaining application information to be stored, the application information comprising a target application identifier and target switching information; determining a first target queue in a stored application queue library according to the target application identifier; updating the first target queue according to the target switching information; and updating the application queue library according to the updated first target queue.

Description

信息存储方法、装置、存储介质及电子设备Information storage method, device, storage medium and electronic device
本申请要求于2017年11月14日提交中国专利局、申请号为201711124553.8、发明名称为“信息存储方法、装置、存储介质及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。The present application claims priority to Chinese Patent Application No. 200911124553.8, entitled "Information Storage Method, Apparatus, Storage Medium, and Electronic Equipment", filed on November 14, 2017, the entire contents of which are incorporated by reference. In this application.
技术领域Technical field
本申请涉及计算机技术领域,尤其涉及一种信息存储方法、装置、存储介质及电子设备。The present application relates to the field of computer technologies, and in particular, to an information storage method, apparatus, storage medium, and electronic device.
背景技术Background technique
随着科技的发展,智能手机、平板电脑(PAD)等移动终端已经成为用户生活中不可或缺的设备。With the development of technology, mobile terminals such as smartphones and tablet PCs (PADs) have become indispensable devices in user life.
目前,由于应用程序的种类越来越多,终端内经常会存在多个应用程序同时运行的情况,这些应用程序除了前台应用是可视之外,更多的是以不可视的形式在后台偷偷运行,而对于这些不可视的后台应用,用户常常会忘记关闭,从而导致过多的后台应用占用大量系统资源,针对这种情况,现有终端通常具有后台应用自动清理功能,这种功能是基于用户已往的使用习惯来实现的,而该使用习惯主要根据用户的app操作记录分析得到,也即终端需要在系统内存中实时记录用户的app操作数据,并根据该app操作数据得出该用户的使用习惯。由于app操作数据是不断变化的,若全部存储在内存中,其数据量比较庞大,难免会占用大量内存空间,影响系统性能。At present, due to the increasing variety of applications, there are often multiple applications running in the terminal at the same time. These applications are visible in addition to the foreground application, and more invisible in the background. Run, and for these invisible background applications, users often forget to close, which leads to too many background applications occupy a lot of system resources. In this case, existing terminals usually have automatic cleaning of background applications, which is based on The user has used the past habits, and the usage habit is mainly based on the user's app operation record analysis, that is, the terminal needs to record the user's app operation data in real time in the system memory, and obtain the user's operation data according to the app operation data. usage habit. Since the app operation data is constantly changing, if all of it is stored in the memory, the amount of data is relatively large, which inevitably consumes a large amount of memory space and affects system performance.
发明内容Summary of the invention
本申请实施例提供一种信息存储方法、装置、存储介质以及电子设备,能减少信息存储时的内存占用,提高存储效果。The embodiment of the present invention provides an information storage method, device, storage medium, and electronic device, which can reduce memory usage during information storage and improve storage effect.
本申请实施例提供了一种信息存储方法,应用于第一电子设备,包括:The embodiment of the present application provides an information storage method, which is applied to a first electronic device, and includes:
获取待存储的应用信息,所述应用信息包括目标应用标识和目标切换信息;Obtaining application information to be stored, where the application information includes target application identifier and target switching information;
根据所述目标应用标识从已存储的应用队列库中确定第一目标队列,所述应用队列库包括至少一个应用队列,每一应用队列包括至少一条切换信息;Determining, according to the target application identifier, a first target queue from the stored application queue library, where the application queue library includes at least one application queue, and each application queue includes at least one switching information;
根据所述目标切换信息对所述第一目标队列进行更新,以在所述应用队列库中存储所述应用信息;Updating the first target queue according to the target switching information, to store the application information in the application queue library;
根据更新后的第一目标队列对所述应用队列库进行更新。The application queue library is updated according to the updated first target queue.
本申请实施例还提供了一种信息存储装置,应用于第一电子设备,包括:The embodiment of the present application further provides an information storage device, which is applied to the first electronic device, and includes:
获取模块,用于获取待存储的应用信息,所述应用信息包括目标应用标识和目标切换信息;An acquiring module, configured to acquire application information to be stored, where the application information includes target application identifier and target switching information;
确定模块,用于根据所述目标应用标识从已存储的应用队列库中确定第一目标队列,所述应用队列库包括至少一个应用队列,每一应用队列包括至少一条切换信息;a determining module, configured to determine, according to the target application identifier, a first target queue from the stored application queue library, where the application queue library includes at least one application queue, and each application queue includes at least one switching information;
第一更新模块,用于根据所述目标切换信息对所述第一目标队列进行更新,以在所述应用队列库中存储所述应用信息;a first update module, configured to update the first target queue according to the target switching information, to store the application information in the application queue library;
第二更新模块,用于根据更新后的第一目标队列对所述应用队列库进行更新。And a second update module, configured to update the application queue library according to the updated first target queue.
本申请实施例还提供了一种存储介质,所述存储介质中存储有多条指令,所述指令适于由处理器加载以执行上述任一项信息存储方法。The embodiment of the present application further provides a storage medium, where the storage medium stores a plurality of instructions, and the instructions are adapted to be loaded by a processor to execute any of the foregoing information storage methods.
本申请实施例还提供了一种电子设备,包括处理器和存储器,所述处理器与所述存储器电性连接,所述存储器用于存储指令和数据,所述处理器用于上述任一项所述的信息存 储方法中的步骤。The embodiment of the present application further provides an electronic device, including a processor and a memory, the processor is electrically connected to the memory, the memory is used to store instructions and data, and the processor is used in any one of the foregoing The steps in the information storage method described.
附图说明DRAWINGS
下面结合附图,通过对本申请的具体实施方式详细描述,将使本申请的技术方案及其它有益效果显而易见。The technical solutions and other advantageous effects of the present application will be apparent from the detailed description of the embodiments of the present application.
图1为本申请实施例提供的信息存储方法的流程示意图。FIG. 1 is a schematic flowchart diagram of an information storage method according to an embodiment of the present application.
图2为本申请实施例提供的信息存储方法的另一流程示意图。FIG. 2 is another schematic flowchart of an information storage method according to an embodiment of the present application.
图3为本申请实施例提供的hashmap的示意图。FIG. 3 is a schematic diagram of a hashmap provided by an embodiment of the present application.
图4为本申请实施例提供的信息存储过程的示意图。FIG. 4 is a schematic diagram of an information storage process provided by an embodiment of the present application.
图5为本申请实施例提供的信息存储装置的结构示意图。FIG. 5 is a schematic structural diagram of an information storage device according to an embodiment of the present disclosure.
图6为本申请实施例提供的第二更新模块的结构示意图。FIG. 6 is a schematic structural diagram of a second update module according to an embodiment of the present application.
图7为本申请实施例提供的信息存储装置的另一结构示意图。FIG. 7 is another schematic structural diagram of an information storage device according to an embodiment of the present disclosure.
图8为本申请实施例提供的电子设备的结构示意图。FIG. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application are clearly and completely described in the following with reference to the drawings in the embodiments of the present application. It is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments obtained by a person skilled in the art based on the embodiments of the present application without creative efforts are within the scope of the present application.
本申请实施例提供一种信息存储方法、装置、存储介质以及电子设备。The embodiment of the present application provides an information storage method, device, storage medium, and electronic device.
一种信息存储方法,应用于第一电子设备,包括:获取待存储的应用信息,该应用信息包括目标应用标识和目标切换信息;根据该目标应用标识从已存储的应用队列库中确定第一目标队列,该应用队列库包括至少一个应用队列,每一应用队列包括至少一条切换信息;根据该目标切换信息对该第一目标队列进行更新,以在该应用队列库中存储该应用信息;根据更新后的第一目标队列对该应用队列库进行更新。An information storage method is applied to the first electronic device, including: acquiring application information to be stored, the application information including target application identifier and target switching information; determining, according to the target application identifier, the first from the stored application queue library a target queue, the application queue library includes at least one application queue, each application queue includes at least one piece of switching information; and the first target queue is updated according to the target switching information to store the application information in the application queue library; The updated first target queue updates the application queue library.
进一步地,所述应用队列库还包括至少一个应用标识,每一应用标识对应一个应用队列,所述根据所述目标应用标识从已存储的应用队列库中确定第一目标队列,包括:Further, the application queue library further includes at least one application identifier, and each application identifier corresponds to one application queue, and the determining, according to the target application identifier, the first target queue from the stored application queue library, including:
将所述目标应用标识与所述应用标识进行匹配;Matching the target application identifier with the application identifier;
若匹配成功,则将所述匹配成功的应用标识对应的应用队列作为第一目标队列;If the matching is successful, the application queue corresponding to the successfully matched application identifier is used as the first target queue;
若匹配失败,则在所述应用队列库中存储所述目标应用标识,并创建一个与所述目标应用标识对应的空应用队列,作为第一目标队列。If the matching fails, the target application identifier is stored in the application queue library, and an empty application queue corresponding to the target application identifier is created as the first target queue.
进一步地,所述根据所述目标切换信息对所述第一目标队列进行更新,包括:Further, the updating, by the target switching information, the first target queue includes:
在所述第一目标队列的队尾存储所述目标切换信息;And storing the target switching information at a tail of the first target queue;
当所述目标切换信息加入成功时,统计所述第一目标队列中切换信息的数量,作为第一数量;When the target switching information is successfully added, the number of switching information in the first target queue is counted as the first quantity;
判断所述第一数量是否大于第一预设阈值;Determining whether the first quantity is greater than a first preset threshold;
若是,则将所述第一目标队列中排位最靠前的预设条数切换信息进行删除。If yes, the preset number of pieces of switching information in the first target queue is deleted.
进一步地,所述根据更新后的第一目标队列对所述应用队列库进行更新,包括:Further, the updating the application queue library according to the updated first target queue includes:
统计每一应用队列中切换信息的数量,作为第二数量;Counting the number of switching information in each application queue as the second quantity;
按照所述第二数量从大到小的顺序对所述应用队列库中的应用队列进行排序,得到排序后队列库,并根据所述第二数量计算总数量;Sorting application queues in the application queue library according to the second quantity from large to small, obtaining a sorted queue library, and calculating a total quantity according to the second quantity;
根据所述总数量对所述排序后队列库进行更新。The sorted queue library is updated according to the total number.
进一步地,所述根据所述总数量对所述排序后队列库进行更新,包括:Further, the updating the sorted queue library according to the total quantity comprises:
判断所述总数量是否大于第二预设阈值;Determining whether the total quantity is greater than a second preset threshold;
若是,则选取所述排序后队列库中排位最靠前的应用队列,作为待更新队列;If yes, the application queue with the highest ranking in the ranked queue library is selected as the queue to be updated;
获取所述待更新队列对应的第二数量,并根据预设比例和所述待更新队列对应的第二数量确定目标数量;Obtaining a second quantity corresponding to the to-be-updated queue, and determining a target quantity according to a preset ratio and a second quantity corresponding to the to-be-updated queue;
删除所述待更新队列中前目标数量条切换信息,以对所述待更新队列进行更新。Deleting the previous target quantity bar switching information in the queue to be updated to update the to-be-updated queue.
进一步地,在删除所述待更新队列中前目标数量条切换信息之后,所述信息存储方法还包括:Further, after deleting the previous target quantity strip switching information in the queue to be updated, the information storage method further includes:
计算当前所述总数量和目标数量之间的差值;Calculating the difference between the current total quantity and the target quantity;
判断所述差值是否小于或等于第三预设阈值,所述第二预设阈值大于第三预设阈值;Determining whether the difference is less than or equal to a third preset threshold, where the second preset threshold is greater than a third preset threshold;
若否,则将所述排序后队列库中的下一应用队列作为待更新队列,将所述差值作为总数量,并返回执行获取所述待更新队列对应的第二数量的操作,直至所有应用队列更新完毕。If no, the next application queue in the sorted queue library is used as the queue to be updated, and the difference is used as the total number, and the operation is performed to obtain the second quantity corresponding to the queue to be updated until all The application queue is updated.
进一步地,在根据更新后的第一目标队列对所述应用队列库进行更新之后,所述信息存储方法还包括:Further, after updating the application queue library according to the updated first target queue, the information storage method further includes:
获取同步存储指令;Obtaining a synchronous storage instruction;
根据所述同步存储指令获取所述应用队列库中的应用标识;Obtaining an application identifier in the application queue library according to the synchronous storage instruction;
对所述应用标识进行加密,得到加密标识;Encrypting the application identifier to obtain an encrypted identifier;
根据所述加密标识将相应应用队列中的切换信息存储在第二电子设备中。The switching information in the corresponding application queue is stored in the second electronic device according to the encrypted identifier.
进一步地,所述获取同步存储指令,包括:Further, the acquiring the synchronous storage instruction includes:
检测所述第一电子设备是否接收到关机指令,或者是否到达指定时间;Detecting whether the first electronic device receives a shutdown command, or whether a specified time is reached;
若是,则生成同步存储指令。If so, a synchronous store instruction is generated.
进一步地,在根据所述加密标识将相应应用队列中的切换信息存储在第二电子设备中之后,所述信息存储方法还包括:Further, after the switching information in the corresponding application queue is stored in the second electronic device according to the encryption identifier, the information storage method further includes:
获取开机指令;Obtain a boot command;
根据所述开机指令从所述第二电子设备中获取加密标识、以及所述加密标识对应的切换信息;Acquiring an encrypted identifier and the switching information corresponding to the encrypted identifier from the second electronic device according to the booting instruction;
对所述加密标识进行解密,得到所述应用标识;Decrypting the encrypted identifier to obtain the application identifier;
根据所述应用标识和对应的切换信息建立所述应用队列库。And establishing the application queue library according to the application identifier and corresponding switching information.
如图1所示,该信息存储方法的具体流程可以如下:As shown in FIG. 1, the specific process of the information storage method can be as follows:
101、获取待存储的应用信息,该应用信息包括目标应用标识和目标切换信息。101. Acquire application information to be stored, where the application information includes target application identifier and target switching information.
本实施例中,该应用标识(或目标应用标识)是应用程序的唯一识别标志,其可以是应用名称。该切换信息(或目标切换信息)主要指应用切换至前台时的相关信息,比如切换时刻、被切换的上一前台应用等。In this embodiment, the application identifier (or target application identifier) is a unique identifier of the application, which may be an application name. The switching information (or the target switching information) mainly refers to related information when the application switches to the foreground, such as the switching time, the last foreground application that is switched, and the like.
102、根据该目标应用标识从已存储的应用队列库中确定第一目标队列,该应用队列库包括至少一个应用队列,每一应用队列包括至少一条切换信息。102. Determine, according to the target application identifier, a first target queue from the stored application queue library, where the application queue library includes at least one application queue, and each application queue includes at least one switching information.
本实施例中,该应用队列库用于存储历史时段内已切换至前台的所有应用的切换信息,每一切换信息是按切换时间的先后顺序在相应应用队列中进行存储的,该应用队列可以是FIFO(First Input First Output,先入先出)队列,其是一种先进先出的数据结构,只能顺序写入切换信息,顺序读出切换信息。In this embodiment, the application queue library is used to store switching information of all applications that have been switched to the foreground in the historical period, and each switching information is stored in the corresponding application queue in the order of switching time, and the application queue may be It is a FIFO (First Input First Output) queue, which is a FIFO data structure, which can only sequentially write switching information and sequentially read switching information.
例如,该应用队列库还包括至少一个应用标识,每一应用标识对应一个应用队列,此时,上述步骤102具体可以包括:For example, the application queue library further includes at least one application identifier, and each application identifier corresponds to one application queue. In this case, the foregoing step 102 may specifically include:
将该目标应用标识与该应用标识进行匹配;Matching the target application identifier with the application identifier;
若匹配成功,则将该匹配成功的应用标识对应的应用队列作为第一目标队列;If the matching is successful, the application queue corresponding to the successfully matched application identifier is used as the first target queue;
若匹配失败,则在该应用队列库中存储该目标应用标识,并创建一个与该目标应用标识对应的空应用队列,作为第一目标队列。If the matching fails, the target application identifier is stored in the application queue library, and an empty application queue corresponding to the target application identifier is created as the first target queue.
本实施例中,该应用队列库中已存储的应用队列和应用标识是关联存储的,比如可以将应用标识作为键(Key),将应用队列作为该键的值(Value)进行关联。电子设备可以提前建立每个应用的应用队列,也可以在应用首次启动时才建立对应应用队列。当应用首次启动才创建对应应用队列时,若应用队列库中不存在当前前台应用的应用队列,可以根据当前前台应用的应用标识建立一个空的先入先出队列,作为当前前台应用的应用队列。In this embodiment, the application queue and the application identifier stored in the application queue library are stored in association. For example, the application identifier may be used as a key, and the application queue is associated with the value of the key. The electronic device can establish an application queue for each application in advance, or can establish a corresponding application queue when the application is first started. If the application queue is created when the application is started for the first time, if there is no application queue of the current foreground application in the application queue, an empty first-in first-out queue can be established according to the application identifier of the current foreground application, as the application queue of the current foreground application.
103、根据该目标切换信息对该第一目标队列进行更新,以在该应用队列库中存储该应用信息。103. Update the first target queue according to the target switching information to store the application information in the application queue library.
例如,上述步骤103具体可以包括:For example, the foregoing step 103 may specifically include:
在该第一目标队列的队尾存储该目标切换信息;Storing the target switching information at the end of the first target queue;
当该目标切换信息加入成功时,统计该第一目标队列中切换信息的数量,作为第一数量;When the target switching information is successfully added, the number of switching information in the first target queue is counted as the first quantity;
判断该第一数量是否大于第一预设阈值;Determining whether the first quantity is greater than a first preset threshold;
若是,则将该第一目标队列中排位最靠前的预设条数切换信息进行删除。If yes, the preset number of pieces of switching information in the first target queue is deleted.
本实施例中,对于先入先出的应用队列,每次获取到新的切换信息时,可以将该新的切换信息存储在相应应用队列的末尾。该第一预设阈值可以根据实际内存大小而定,实际内存越大,其第一预设阈值可以越大,比如该第一预设阈值可以为100。该预设条数可以是人为设定的数值,比如5。通常,由于高频使用应用(简称高频应用)切换至前台的次数比较多,故其对应的应用队列中存储的切换信息也应较多(也即队列长度较长),为避免高频应用的切换信息过多的占用系统内存,从而导致没有足够的内存存储低频应用的切换信息,可以限定每个应用队列的最大长度(第一预设阈值),也即每当有新的切换信息存储在对应应用队列中时,可以检测该应用队列的长度是否超过最大长度,若超过,则进行数据删减,考虑到距离当前时间越久远的数据参考价值越低,故可以将存储时间最久(也即排在应用队列前面)的单个或部分切换信息进行删除。In this embodiment, for the first-in first-out application queue, each time the new switching information is acquired, the new switching information may be stored at the end of the corresponding application queue. The first preset threshold may be determined according to the actual memory size. The larger the actual memory, the larger the first preset threshold may be. For example, the first preset threshold may be 100. The preset number can be an artificially set value, such as 5. Generally, since the frequency of high frequency application (referred to as high frequency application) is switched to the foreground more frequently, the switching information stored in the corresponding application queue should also be more (that is, the queue length is longer), in order to avoid high frequency application. Excessive switching information occupies system memory, resulting in insufficient memory to store switching information of low frequency applications, and can limit the maximum length of each application queue (first preset threshold), that is, whenever there is new switching information storage When the corresponding application queue is used, it can detect whether the length of the application queue exceeds the maximum length. If it exceeds, the data is deleted. Considering that the data reference value is longer than the current time, the storage time can be the longest ( That is, single or partial switching information that is listed in front of the application queue is deleted.
104、根据更新后的第一目标队列对该应用队列库进行更新。104. Update the application queue library according to the updated first target queue.
例如,上述步骤104具体可以包括:For example, the foregoing step 104 may specifically include:
统计每一应用队列中切换信息的数量,作为第二数量;Counting the number of switching information in each application queue as the second quantity;
按照该第二数量从大到小的顺序对该应用队列库中的应用队列进行排序,得到排序后队列库,并根据该第二数量计算总数量;Sorting the application queues in the application queue library according to the second quantity from the largest to the smallest, obtaining the sorted queue library, and calculating the total quantity according to the second quantity;
根据该总数量对该排序后队列库进行更新。The sorted queue library is updated according to the total number.
本实施例中,由于该应用队列库通常存储在电子设备的系统内存中,为避免内存空间占用过多,可以将数据量控制在一定规模内,也即每次存储了新的切换信息时,都需要检测该应用队列库中切换信息的总量,根据该总量来决定需不需要进行数据删减。In this embodiment, since the application queue library is usually stored in the system memory of the electronic device, in order to avoid excessive use of the memory space, the data amount may be controlled within a certain scale, that is, each time a new switching information is stored, It is necessary to detect the total amount of switching information in the application queue library, and according to the total amount, it is determined that data deletion is not required.
例如,上述步骤“根据该总数量对该排序后队列库进行更新”具体可以包括:For example, the foregoing step of “updating the sorted queue library according to the total quantity” may specifically include:
判断该总数量是否大于第二预设阈值;Determining whether the total quantity is greater than a second preset threshold;
若是,则选取该排序后队列库中排位最靠前的应用队列,作为待更新队列;If yes, the application queue with the highest ranking in the ranked queue library is selected as the queue to be updated;
获取该待更新队列对应的第二数量,并根据预设比例和该待更新队列对应的第二数量确定目标数量;Obtaining a second quantity corresponding to the to-be-updated queue, and determining a target quantity according to a preset ratio and a second quantity corresponding to the to-be-updated queue;
删除该待更新队列中前目标数量条切换信息,以对该待更新队列进行更新。The previous target quantity bar switching information in the queue to be updated is deleted to update the to-be-updated queue.
本实施例中,该第二预设阈值和预设比例可以是人为设定的,比如该第二预设阈值可以是1000,该预设比例可以是10%。当应用队列库中切换信息的总量超过第二预设阈值时,可以按照使用频率从高到底的顺序依次对应用的切换信息进行删减,首次删减时,选取的通常是排序后队列库中第一位的应用队列。In this embodiment, the second preset threshold and the preset ratio may be manually set. For example, the second preset threshold may be 1000, and the preset ratio may be 10%. When the total amount of the switching information in the application queue library exceeds the second preset threshold, the switching information of the application may be sequentially deleted according to the frequency of use from the highest to the lowest. When the first deletion is performed, the queue after the sorting is usually selected. The first application queue in the middle.
进一步地,在删除该待更新队列中前目标数量条切换信息之后,该信息存储方法还可以包括:Further, after deleting the previous target quantity strip switching information in the queue to be updated, the information storage method may further include:
计算当前该总数量和目标数量之间的差值;Calculating the difference between the current total quantity and the target quantity;
判断该差值是否小于或等于第三预设阈值,该第二预设阈值大于第三预设阈值;Determining whether the difference is less than or equal to a third preset threshold, where the second preset threshold is greater than a third preset threshold;
若是,则将该排序后队列库中的下一应用队列作为待更新队列,将该差值作为总数量,并返回执行获取该待更新队列对应的第二数量的操作,直至所有应用队列更新完毕。If yes, the next application queue in the sorted queue library is used as the queue to be updated, and the difference is taken as the total quantity, and the operation of obtaining the second quantity corresponding to the queue to be updated is performed until all application queues are updated. .
本实施例中,该第三预设阈值可以是人为设定的一个最佳存储量,比如800。当每次对单个应用队列进行删减之后,该应用队列库中切换信息的总量都会发生变化,若每次检测的总量都超过最佳存储量,则需要继续选取下一应用队列进行删减,直到总量小于或等于最佳存储量时停止。In this embodiment, the third preset threshold may be an optimal storage amount manually set, such as 800. After the single application queue is deleted, the total amount of switching information in the application queue library changes. If the total amount of detection exceeds the optimal storage amount, the next application queue needs to be selected for deletion. Decrease until the total amount is less than or equal to the optimal storage amount.
此外,由于一般的电子设备都有掉电保护策略,也即系统内存中存储的数据在断电的情况下会自动清零,为避免断电后该应用队列库中存储的数据丢失,可以定期将其同步到外部存储设备中,也即,在上述步骤104之后,该信息存储方法还可以包括:In addition, since the general electronic device has a power-down protection strategy, that is, the data stored in the system memory is automatically cleared in the case of power failure, in order to avoid data loss stored in the application queue library after the power failure, it may be periodically Synchronizing the information to the external storage device, that is, after the above step 104, the information storage method may further include:
获取同步存储指令;Obtaining a synchronous storage instruction;
根据该同步存储指令获取该应用队列库中的应用标识;Obtaining an application identifier in the application queue library according to the synchronous storage instruction;
对该应用标识进行加密,得到加密标识;Encrypting the application identifier to obtain an encrypted identifier;
根据该加密标识将相应应用队列中的切换信息存储在第二电子设备中。The switching information in the corresponding application queue is stored in the second electronic device according to the encrypted identifier.
本实施例中,该同步存储指令可以是在关机或者到达指定时间后自动生成的,具体的,电子设备可以设置一个定时器,该定时器可以每隔一定时长(比如一个小时)或接收到关机信息就触发生成该同步存储指令。该加密方法可以根据实际需求而定,比如可以为AES(Advanced Encryption Standard,高级加密标准),其是一种对称加密算法,也即使用相同的密钥加密和解密数据。该第二电子设备主要指外部存储设备,比如存储服务器或者硬盘等。In this embodiment, the synchronous storage instruction may be automatically generated after the shutdown or the specified time is reached. Specifically, the electronic device may set a timer, and the timer may be shut down at a certain time (such as one hour) or received. The information triggers the generation of the synchronous store instruction. The encryption method may be determined according to actual needs, such as AES (Advanced Encryption Standard), which is a symmetric encryption algorithm, that is, encrypting and decrypting data using the same key. The second electronic device mainly refers to an external storage device, such as a storage server or a hard disk.
需要强调的是,由于应用的切换信息关系到用户的使用习惯,为避免外部存储设备在丢失或被盗时泄露用户隐私,可以在同步存储过程中对应用标识进行加密,当然,由于先入先出队列具有一定的数据结构,为避免存储过程中发生乱码,可以只在外部存储设备中存储加密标识和切换信息,具体的,电子设备可以在将加密标识写入外部存储设备之后,再写入回车作为行分割,然后依次写入对应应用队列中的切换信息,写完后同样写入回车作为行分割,接着开始写入下一个加密标识及其对应的切换信息,直至所有加密标识和切换信息写入完毕。It should be emphasized that, because the switching information of the application is related to the user's usage habits, in order to prevent the external storage device from leaking the user's privacy when it is lost or stolen, the application identifier may be encrypted in the synchronous storage process, of course, due to the first in first out. The queue has a certain data structure. To avoid garbled characters in the storage process, the encryption identifier and the switching information can be stored only in the external storage device. Specifically, the electronic device can write the encrypted identifier to the external storage device and then write it back. The car is divided into rows, and then written to the switching information in the corresponding application queue. After writing, the carriage return is also written as the line division, and then the next encryption identifier and its corresponding switching information are written, until all the encryption identifiers and switching are performed. The information has been written.
容易理解的是,由于每次断电后系统内存中的数据都会清零,故电子设备可以在开机后自动将外部存储存储设备中的数据同步到内存中,以便后续查询和使用,也即,在根据该加密标识将相应应用队列中的切换信息存储在第二电子设备中之后,该信息存储方法还可以包括:It is easy to understand that since the data in the system memory is cleared after each power failure, the electronic device can automatically synchronize the data in the external storage storage device into the memory after booting, so as to be subsequently queried and used, that is, After the switching information in the corresponding application queue is stored in the second electronic device according to the encrypted identifier, the information storage method may further include:
获取开机指令;Obtain a boot command;
根据该开机指令从该第二电子设备中获取加密标识、以及该加密标识对应的切换信息;And acquiring, according to the booting instruction, the encrypted identifier and the switching information corresponding to the encrypted identifier from the second electronic device;
对该加密标识进行解密,得到该应用标识;Decrypting the encrypted identifier to obtain the application identifier;
根据该应用标识和对应的切换信息建立该应用队列库。The application queue library is established according to the application identifier and the corresponding switching information.
本实施例中,对于AES加密算法,可以使用同样的秘钥对加密标识进行解密,还原得到应用标识,然后可以先建立一个与应用标识对应的空的先入先出队列,并在该空的先入先出队列中依次写入加密标识对应的切换信息,从而还原得到该应用队列。In this embodiment, for the AES encryption algorithm, the same key can be used to decrypt the encrypted identifier, and the application identifier is restored, and then an empty first in first out queue corresponding to the application identifier can be established first, and the empty first ingress is created. The switching information corresponding to the encrypted identifier is sequentially written in the first-out queue, thereby restoring the application queue.
由上述可知,本实施例提供的信息存储方法,应用于第一电子设备,通过获取待存储的应用信息,该应用信息包括目标应用标识和目标切换信息,并根据该目标应用标识从已存储的应用队列库中确定第一目标队列,该应用队列库包括至少一个应用队列,每一应用队列包括至少一条切换信息,之后根据该目标切换信息对该第一目标队列进行更新,以在该应用队列库中存储该应用信息,并根据更新后的第一目标队列对该应用队列库进行更新, 从而在应用信息的存储过程中,不仅能减少系统内存占用量,还可以较好地保证数据的全面性,方法简单,存储效果好。The information storage method provided in this embodiment is applied to the first electronic device, and the application information includes the target application identifier and the target switching information, and the target application identifier is stored according to the target application identifier. Determining a first target queue in the application queue library, the application queue library includes at least one application queue, each application queue includes at least one switching information, and then updating the first target queue according to the target switching information, in the application queue The application information is stored in the library, and the application queue library is updated according to the updated first target queue, so that in the storage process of the application information, not only the system memory consumption can be reduced, but also the data is comprehensively ensured. Sex, simple method, good storage effect.
在本实施例中,将以该信息存储装置具体集成在第一电子设备中为例进行详细说明。In this embodiment, the information storage device is specifically integrated into the first electronic device as an example for detailed description.
请参见图2,一种信息存储方法,具体流程可以如下:Referring to FIG. 2, an information storage method may be as follows:
201、第一电子设备获取待存储的应用信息,该应用信息包括目标应用标识和目标切换信息。201. The first electronic device acquires application information to be stored, where the application information includes a target application identifier and target switching information.
譬如,可以实时监测前台运行应用,当发现该前台运行应用发生变化时,可以将变化后的运行应用的应用标识、变化前的运行应用的应用标识、以及变化时刻作为待存储的应用信息。For example, the application running in the foreground can be monitored in real time. When the application running in the foreground is changed, the application identifier of the changed running application, the application identifier of the running application before the change, and the changed time are used as the application information to be stored.
202、第一电子设备将该目标应用标识与已存储的应用队列库中的应用标识进行匹配,若匹配成功,则将该匹配成功的应用标识对应的应用队列作为第一目标队列,若匹配失败,则在该应用队列库中存储该目标应用标识,并创建一个与该目标应用标识对应的空应用队列,作为第一目标队列。The first electronic device matches the target application identifier with the application identifier in the stored application queue library. If the matching is successful, the application queue corresponding to the successfully matched application identifier is used as the first target queue, and the matching fails. And storing the target application identifier in the application queue library, and creating an empty application queue corresponding to the target application identifier, as the first target queue.
譬如,请参见图3,当用户启动某一app时,可以通过hashmap(哈希映射)在电子设备中建立该App对应的切换信息,其中key为app应用名,value为一个先入先出的FiFo(先入先出)队列,每个FiFo队列对应相应app的切换信息。比如,该应用队列库中存储的应用标识可以包括{App1、App2…Appx},该目标应用标识可以为Appi,此时,可以根据i查询hashmap,若i∈(1、2…x),则表明匹配成功,匹配成功的应用队列即为Appi对应的应用队列,若
Figure PCTCN2018115268-appb-000001
则表明匹配失败,需要创建Appi对应的FiFo队列。
For example, referring to FIG. 3, when the user starts an app, the switch information corresponding to the App can be established in the electronic device through a hashmap, where the key is the app name and the value is a first-in, first-out FiFo. (first in, first out) queue, each FiFo queue corresponds to the switching information of the corresponding app. For example, the application identifier stored in the application queue library may include {App1, App2...Appx}, and the target application identifier may be Appi. In this case, the hashmap may be queried according to i, if i∈(1, 2...x), then If the match is successful, the matching application queue is the application queue corresponding to Appi.
Figure PCTCN2018115268-appb-000001
If the match fails, you need to create a FiFo queue corresponding to Appi.
203、第一电子设备在该第一目标队列的队尾存储该目标切换信息,并当该目标切换信息加入成功时,统计该第一目标队列中切换信息的数量,作为第一数量。203. The first electronic device stores the target switching information at the tail of the first target queue, and when the target switching information is successfully added, the number of the switching information in the first target queue is counted as the first quantity.
204、第一电子设备判断该第一数量是否大于第一预设阈值,若是,则将该第一目标队列中排位最靠前的预设条数切换信息进行删除,若否,则可以直接执行下述步骤205。204. The first electronic device determines whether the first quantity is greater than a first preset threshold, and if yes, deleting the preset number of switching information in the first target queue, if not, directly Perform the following step 205.
譬如,该第一预设阈值(QueueMax)可以是100,该预设条数可以是1,Appi对应的应用队列为Queuei,Queuei中可以包括Ni条切换信息,比如Appi_1、Appi_2...Appi_Ni,当Appi对应的FIFO队列中已存储的切换信息超过100条,也即Ni>100时,需要删除切换信息Appi_1。For example, the first preset threshold (QueueMax) may be 100, the preset number of entries may be 1, and the application queue corresponding to Appi is Queuei, and the Queuei may include Ni strip switching information, such as Appi_1, Appi_2, ... Appi_Ni, When the switching information stored in the FIFO queue corresponding to Appi exceeds 100, that is, Ni>100, the switching information Appi_1 needs to be deleted.
205、第一电子设备统计每一应用队列中切换信息的数量,作为第二数量,并按照该第二数量从大到小的顺序对该应用队列库中的应用队列进行排序,得到排序后队列库,之后根据该第二数量计算总数量。205. The first electronic device collects the number of switching information in each application queue as the second quantity, and sorts the application queues in the application queue library according to the second quantity in descending order, and obtains the sorted queue. The library, after which the total quantity is calculated based on the second quantity.
譬如,若应用队列库中包括{Queue1、Queue2...QueueX}这X个应用队列,每个应用队列中切换信息的第二数量依次可以为{N1、N2...NX},则可以根据每个应用队列对应的第二数量的数值对它们进行排序,切换信息越多,排位越靠前,切换信息越少,排位越靠后,比如排序后的的应用队列库可以为Queue5、Queue2...QueueX-1。For example, if the application queue library includes X application queues of {Queue1, Queue2...QueueX}, and the second number of switching information in each application queue may be {N1, N2... NX}, then The second number of values corresponding to each application queue sorts them. The more switching information, the higher the ranking, the less the switching information, the lower the ranking, for example, the sorted application queue library can be Queue5, Queue2...QueueX-1.
206、第一电子设备判断该总数量是否大于第二预设阈值,若是,则执行下述步骤207,若否,则可以执行下述步骤210。206. The first electronic device determines whether the total quantity is greater than a second preset threshold. If yes, performing the following step 207. If not, performing the following step 210.
207、第一电子设备选取该排序后队列库中排位最靠前的应用队列,作为待更新队列,并获取该待更新队列对应的第二数量。207. The first electronic device selects the top-ranked application queue in the sorted queue library as the queue to be updated, and obtains the second quantity corresponding to the queue to be updated.
208、第一电子设备根据预设比例和该待更新队列对应的第二数量确定目标数量,并删除该待更新队列中前目标数量条切换信息,以对该待更新队列进行更新。208. The first electronic device determines the target quantity according to the preset ratio and the second quantity corresponding to the to-be-updated queue, and deletes the previous target quantity quantity switching information in the to-be-updated queue to update the to-be-updated queue.
譬如,该第二预设阈值可以是1000,该预设比例可以是10%。可以计算N1、N2...Nx的总和SUM,若SUM大于1000,比如1005时,可以获取排位第一的Queue5,若Queue5中的切换信息的第二数量N5为90,则该目标数量为90*10%=9,也即选取前9条切换信息进行删除。For example, the second preset threshold may be 1000, and the preset ratio may be 10%. The sum SUM of N1, N2...Nx can be calculated. If SUM is greater than 1000, such as 1005, the first queue Queue5 can be obtained. If the second number N5 of the switching information in Queue5 is 90, the target quantity is 90*10%=9, that is, the first 9 pieces of switching information are selected for deletion.
209、第一电子设备计算当前该总数量和目标数量之间的差值,并判断该差值是否小于或等于第三预设阈值,该第二预设阈值大于第三预设阈值,若否,则将该排序后队列库中的下一应用队列作为待更新队列,将该差值作为总数量,并返回执行上述步骤208,若是,则可以执行下述步骤210。209. The first electronic device calculates a difference between the current total quantity and the target quantity, and determines whether the difference is less than or equal to a third preset threshold. The second preset threshold is greater than a third preset threshold. Then, the next application queue in the sorted queue library is used as the queue to be updated, and the difference is taken as the total number, and the above step 208 is performed, and if so, the following step 210 can be performed.
譬如,该第三预设阈值可以为800,由于对Queue5删减后应用队列库中切换信息的总数量SUM变为1005-9=996>800,因此,还要继续从应用队列库中选取排位第二的Queue2继续进行删减,此时删减的目标数量为N2*10%,之后,继续计算删减后的总数量SUM,如此循环,直至SUM≤800时结束。For example, the third preset threshold may be 800. Since the total number of switching information in the application queue library after the Queue 5 is deleted is changed to 1005-9=996>800, the row is still selected from the application queue library. The second Queue2 continues to be deleted. At this time, the number of targets to be deleted is N2*10%. Thereafter, the total number SUM after the deletion is continued, and the loop is repeated until SUM ≤ 800.
210、第一电子设备获取同步存储指令,并根据该同步存储指令获取该应用队列库中的应用标识。210. The first electronic device acquires a synchronous storage instruction, and acquires an application identifier in the application queue library according to the synchronous storage instruction.
譬如,请参见图4,第一电子设备可以设置一个定时器,该定时器可以每隔一个小时就触发生成该同步存储指令,当然,也可以是在关机时自动生成该同步存储指令。For example, referring to FIG. 4, the first electronic device may set a timer, which may trigger the generation of the synchronous storage instruction every hour. Of course, the synchronous storage instruction may be automatically generated when the power is turned off.
211、第一电子设备对该应用标识进行加密,得到加密标识,并根据该加密标识将相应应用队列中的切换信息存储在第二电子设备中。211. The first electronic device encrypts the application identifier, obtains an encrypted identifier, and stores the switching information in the corresponding application queue in the second electronic device according to the encrypted identifier.
譬如,可以通过AES加密算法对{App1、App2…Appx}进行加密,得到加密标识,并可以在将加密标识写入外部存储设备之后,再写入回车作为行分割,然后依次写入对应应用队列中的切换信息,写完后同样写入回车作为行分割,接着开始写入下一个加密标识及其对应的切换信息,直至所有加密标识和切换信息写入完毕。For example, {App1, App2...Appx} can be encrypted by the AES encryption algorithm to obtain an encrypted identifier, and after the encrypted identifier is written to the external storage device, the carriage return is written as a line division, and then the corresponding application is sequentially written. The switching information in the queue is also written to the carriage return as a line division after writing, and then the next encryption identifier and its corresponding switching information are written until all the encryption identifiers and switching information are written.
212、第一电子设备获取开机指令,并根据该开机指令从该第二电子设备中获取加密标识、以及该加密标识对应的切换信息。212. The first electronic device obtains a booting instruction, and obtains an encrypted identifier and a switching information corresponding to the encrypted identifier from the second electronic device according to the booting instruction.
213、第一电子设备对该加密标识进行解密,得到该应用标识,并根据该应用标识和对应的切换信息建立该应用队列库。213. The first electronic device decrypts the encrypted identifier, obtains the application identifier, and establishes the application queue library according to the application identifier and the corresponding switching information.
譬如,第一电子设备可以在开机时,主动从外部存储设备中获取存储内容,然后通过解密及数据结构重建还原出hashmap。For example, the first electronic device can actively obtain the stored content from the external storage device when the device is powered on, and then restore the hashmap through decryption and data structure reconstruction.
由上述可知,本实施例提供的信息存储方法,其中第一电子设备可以获取待存储的应用信息,该应用信息包括目标应用标识和目标切换信息,并将该目标应用标识与已存储的应用队列库中的应用标识进行匹配,若匹配成功,则将该匹配成功的应用标识对应的应用队列作为第一目标队列,若匹配失败,则在该应用队列库中存储该目标应用标识,并创建一个与该目标应用标识对应的空应用队列,作为第一目标队列,接着,在该第一目标队列的队尾存储该目标切换信息,并当该目标切换信息加入成功时,统计该第一目标队列中切换信息的数量,作为第一数量,接着,判断该第一数量是否大于第一预设阈值,若是,则将该第一目标队列中排位最靠前的预设条数切换信息进行删除,若否,则统计每一应用队列中切换信息的数量,作为第二数量,并按照该第二数量从大到小的顺序对该应用队列库中的应用队列进行排序,得到排序后队列库,之后根据该第二数量计算总数量,接着,判断该总数量是否大于第二预设阈值,若是,则选取该排序后队列库中排位最靠前的应用队列,作为待更新队列,并获取该待更新队列对应的第二数量,接着,根据预设比例和该待更新队列对应的第二数量确定目标数量,并删除该待更新队列中前目标数量条切换信息,以对该待更新队列进行更新,接着,计算当前该总数量和目标数量之间的差值,并判断该差值是否小于或等于第三预设阈值,该第二预设阈值大于第三预设阈值,若是,则将该排序后队列库中的下一应用队列作为待更新队列,将该差值作为总数量,并返回执行判断该总数量是否大于第二预设阈值的操作,从而在应用信息的存储过程中,不仅能减少系统内存占用量,还可以较好地保证数据的全面性,方法简单,存储效果好,之后,第一电子设备可以获取同步存储指令,并根据该同步存储指令获取该应用队列库中的应用标识,接着,对该应用标识进行加密,得到加密标识,并根据该加密标识将相应应用队列中的切换信息 存储在第二电子设备中,从而可以较好地完成数据的备份操作,具有一定的掉电保护策略,避免因断电导致的数据丢失,之后,第一电子设备可以获取开机指令,并根据该开机指令从该第二电子设备中获取加密标识、以及该加密标识对应的切换信息,接着,对该加密标识进行解密,得到该应用标识,并根据该应用标识和对应的切换信息建立该应用队列库,从而可以在断电之后有效的还原丢失数据,可靠性高。The information storage method provided in this embodiment, wherein the first electronic device can acquire the application information to be stored, the application information includes the target application identifier and the target switching information, and the target application identifier and the stored application queue are The application identifier in the library is matched. If the matching is successful, the application queue corresponding to the successfully matched application identifier is used as the first target queue. If the matching fails, the target application identifier is stored in the application queue library, and a An empty application queue corresponding to the target application identifier is used as the first target queue, and then the target switching information is stored at the tail of the first target queue, and when the target switching information is successfully added, the first target queue is counted. The number of the information to be switched is the first quantity. Then, it is determined whether the first quantity is greater than the first preset threshold. If yes, the preset number of the last number of the first target queue is deleted. If not, the number of switching information in each application queue is counted as the second quantity, and according to the second Sorting the application queues in the application queue library from the largest to the smallest, obtaining the sorted queue library, and then calculating the total quantity according to the second quantity, and then determining whether the total quantity is greater than a second preset threshold, if Then, the application queue of the highest ranked queue in the queued queue is selected as the queue to be updated, and the second quantity corresponding to the queue to be updated is obtained, and then, according to the preset ratio and the second corresponding to the queue to be updated The quantity determines the target quantity, and deletes the previous target quantity bar switching information in the queue to be updated to update the to-be-updated queue, and then calculates the current difference between the total quantity and the target quantity, and determines whether the difference is The second preset threshold is greater than or equal to the third preset threshold, and the second preset threshold is greater than the third preset threshold. If yes, the next application queue in the sorted queue library is used as the queue to be updated, and the difference is taken as the total number. And returning to perform an operation of determining whether the total quantity is greater than a second preset threshold, so that not only the system memory usage can be reduced in the storage process of the application information, The data can be comprehensively ensured, the method is simple, and the storage effect is good. After that, the first electronic device can acquire the synchronous storage instruction, and obtain the application identifier in the application queue library according to the synchronous storage instruction, and then apply the application. The identifier is encrypted, and the encrypted identifier is obtained, and the switching information in the corresponding application queue is stored in the second electronic device according to the encrypted identifier, so that the data backup operation can be completed well, and the power-down protection strategy is avoided. After the data is lost due to the power failure, the first electronic device can obtain the power-on command, and obtain the encrypted identifier and the switching information corresponding to the encrypted identifier from the second electronic device according to the power-on command, and then perform the encrypted identifier. Decrypting, obtaining the application identifier, and establishing the application queue library according to the application identifier and the corresponding switching information, so that the lost data can be effectively restored after the power is cut off, and the reliability is high.
根据上述实施例所描述的方法,本实施例将从信息存储装置的角度进一步进行描述,该信息存储装置具体可以作为独立的实体来实现,也可以集成在电子设备,比如终端中来实现,该终端可以包括手机、平板电脑以及个人计算机等。According to the method described in the foregoing embodiments, the present embodiment is further described from the perspective of an information storage device, which may be implemented as an independent entity or integrated in an electronic device, such as a terminal. The terminal can include a mobile phone, a tablet computer, a personal computer, and the like.
本申请实施例提供一种信息存储装置,应用于第一电子设备,包括:The embodiment of the present application provides an information storage device, which is applied to a first electronic device, and includes:
获取模块,用于获取待存储的应用信息,所述应用信息包括目标应用标识和目标切换信息;An acquiring module, configured to acquire application information to be stored, where the application information includes target application identifier and target switching information;
确定模块,用于根据所述目标应用标识从已存储的应用队列库中确定第一目标队列,所述应用队列库包括至少一个应用队列,每一应用队列包括至少一条切换信息;a determining module, configured to determine, according to the target application identifier, a first target queue from the stored application queue library, where the application queue library includes at least one application queue, and each application queue includes at least one switching information;
第一更新模块,用于根据所述目标切换信息对所述第一目标队列进行更新,以在所述应用队列库中存储所述应用信息;a first update module, configured to update the first target queue according to the target switching information, to store the application information in the application queue library;
第二更新模块,用于根据更新后的第一目标队列对所述应用队列库进行更新。And a second update module, configured to update the application queue library according to the updated first target queue.
进一步地,所述应用队列库还包括至少一个应用标识,每一应用标识对应一个应用队列,所述确定模块具体用于:Further, the application queue library further includes at least one application identifier, and each application identifier corresponds to one application queue, and the determining module is specifically configured to:
匹配子模块,用于将所述目标应用标识与所述应用标识进行匹配;a matching submodule, configured to match the target application identifier with the application identifier;
若匹配成功,则将所述匹配成功的应用标识对应的应用队列作为第一目标队列;If the matching is successful, the application queue corresponding to the successfully matched application identifier is used as the first target queue;
若匹配失败,则在所述应用队列库中存储所述目标应用标识,并创建一个与所述目标应用标识对应的空应用队列,作为第一目标队列。If the matching fails, the target application identifier is stored in the application queue library, and an empty application queue corresponding to the target application identifier is created as the first target queue.
进一步地,所述第一更新模块具体用于:Further, the first update module is specifically configured to:
在所述第一目标队列的队尾存储所述目标切换信息;And storing the target switching information at a tail of the first target queue;
当所述目标切换信息加入成功时,统计所述第一目标队列中切换信息的数量,作为第一数量;When the target switching information is successfully added, the number of switching information in the first target queue is counted as the first quantity;
判断所述第一数量是否大于第一预设阈值;Determining whether the first quantity is greater than a first preset threshold;
若是,则将所述第一目标队列中排位最靠前的预设条数切换信息进行删除。If yes, the preset number of pieces of switching information in the first target queue is deleted.
进一步地,所述第二更新模块具体包括:Further, the second update module specifically includes:
统计子模块,用于统计每一应用队列中切换信息的数量,作为第二数量;a statistics sub-module, configured to count the number of switching information in each application queue as a second quantity;
排序子模块,用于按照所述第二数量从大到小的顺序对所述应用队列库中的应用队列进行排序,得到排序后队列库,并根据所述第二数量计算总数量;a sorting sub-module, configured to sort the application queues in the application queue library according to the second quantity from large to small, obtain a sorted queue library, and calculate a total quantity according to the second quantity;
更新子模块,用于根据所述总数量对所述排序后队列库进行更新。An update submodule is configured to update the sorted queue library according to the total number.
进一步地,所述更新子模块具体用于:Further, the update submodule is specifically configured to:
判断所述总数量是否大于第二预设阈值;Determining whether the total quantity is greater than a second preset threshold;
若是,则选取所述排序后队列库中排位最靠前的应用队列,作为待更新队列;If yes, the application queue with the highest ranking in the ranked queue library is selected as the queue to be updated;
获取所述待更新队列对应的第二数量,并根据预设比例和所述待更新队列对应的第二数量确定目标数量;Obtaining a second quantity corresponding to the to-be-updated queue, and determining a target quantity according to a preset ratio and a second quantity corresponding to the to-be-updated queue;
删除所述待更新队列中前目标数量条切换信息,以对所述待更新队列进行更新。Deleting the previous target quantity bar switching information in the queue to be updated to update the to-be-updated queue.
进一步地,在删除所述待更新队列中前目标数量条切换信息之后,所述更新子模块还用于:Further, after deleting the previous target quantity strip switching information in the queue to be updated, the update submodule is further configured to:
计算当前所述总数量和目标数量之间的差值;Calculating the difference between the current total quantity and the target quantity;
判断所述差值是否小于或等于第三预设阈值,所述第二预设阈值大于第三预设阈值;Determining whether the difference is less than or equal to a third preset threshold, where the second preset threshold is greater than a third preset threshold;
若否,则将所述排序后队列库中的下一应用队列作为待更新队列,将所述差值作为总 数量,并返回执行获取所述待更新队列对应的第二数量的操作,直至所有应用队列更新完毕。If no, the next application queue in the sorted queue library is used as the queue to be updated, and the difference is used as the total number, and the operation is performed to obtain the second quantity corresponding to the queue to be updated until all The application queue is updated.
进一步地,所述信息存储装置还包括同步模块,用于:Further, the information storage device further includes a synchronization module, configured to:
在根据更新后的第一目标队列对所述应用队列库进行更新后,获取同步存储指令;After updating the application queue library according to the updated first target queue, acquiring a synchronous storage instruction;
根据所述同步存储指令获取所述应用队列库中的应用标识;Obtaining an application identifier in the application queue library according to the synchronous storage instruction;
对所述应用标识进行加密,得到加密标识;Encrypting the application identifier to obtain an encrypted identifier;
根据所述加密标识将相应应用队列中的切换信息存储在第二电子设备中。The switching information in the corresponding application queue is stored in the second electronic device according to the encrypted identifier.
进一步地,所述同步模块具体用于:Further, the synchronization module is specifically configured to:
检测所述第一电子设备是否接收到关机指令,或者是否到达指定时间;Detecting whether the first electronic device receives a shutdown command, or whether a specified time is reached;
若是,则生成同步存储指令。If so, a synchronous store instruction is generated.
进一步地,所述信息存储装置还包括第二获取模块,用于:Further, the information storage device further includes a second acquiring module, configured to:
在根据所述加密标识将相应应用队列中的切换信息存储在第二电子设备中后,获取开机指令;After the switching information in the corresponding application queue is stored in the second electronic device according to the encrypted identifier, obtaining a booting instruction;
根据所述开机指令从所述第二电子设备中获取加密标识、以及所述加密标识对应的切换信息;Acquiring an encrypted identifier and the switching information corresponding to the encrypted identifier from the second electronic device according to the booting instruction;
对所述加密标识进行解密,得到所述应用标识;Decrypting the encrypted identifier to obtain the application identifier;
根据所述应用标识和对应的切换信息建立所述应用队列库。And establishing the application queue library according to the application identifier and corresponding switching information.
请参阅图5,图5具体描述了本申请实施例提供的信息存储装置,应用于第一电子设备,其可以包括:第一获取模块10、确定模块20、第一更新模块30和第二更新模块40,其中:Referring to FIG. 5, FIG. 5 specifically describes an information storage device provided by an embodiment of the present application, which is applied to a first electronic device, which may include: a first obtaining module 10, a determining module 20, a first updating module 30, and a second update. Module 40, wherein:
(1)第一获取模块10(1) First acquisition module 10
第一获取模块10,用于获取待存储的应用信息,该应用信息包括目标应用标识和目标切换信息。The first obtaining module 10 is configured to acquire application information to be stored, where the application information includes a target application identifier and target switching information.
本实施例中,该应用标识(或目标应用标识)是应用程序的唯一识别标志,其可以是应用名称。该切换信息(或目标切换信息)主要指应用切换至前台时的相关信息,比如切换时刻、被切换的上一前台应用等。In this embodiment, the application identifier (or target application identifier) is a unique identifier of the application, which may be an application name. The switching information (or the target switching information) mainly refers to related information when the application switches to the foreground, such as the switching time, the last foreground application that is switched, and the like.
(2)确定模块20(2) Determination module 20
确定模块,用于根据该目标应用标识从已存储的应用队列库中确定第一目标队列,该应用队列库包括至少一个应用队列,每一应用队列包括至少一条切换信息。And a determining module, configured to determine, according to the target application identifier, a first target queue from the stored application queue library, where the application queue library includes at least one application queue, and each application queue includes at least one switching information.
本实施例中,该应用队列库用于存储历史时段内已切换至前台的所有应用的切换信息,每一切换信息是按切换时间的先后顺序在相应应用队列中进行存储的,该应用队列可以是FIFO(First Input First Output,先入先出)队列,其是一种先进先出的数据结构,只能顺序写入切换信息,顺序读出切换信息。In this embodiment, the application queue library is used to store switching information of all applications that have been switched to the foreground in the historical period, and each switching information is stored in the corresponding application queue in the order of switching time, and the application queue may be It is a FIFO (First Input First Output) queue, which is a FIFO data structure, which can only sequentially write switching information and sequentially read switching information.
例如,该应用队列库还包括至少一个应用标识,每一应用标识对应一个应用队列,该确定模块具体用于:For example, the application queue library further includes at least one application identifier, and each application identifier corresponds to one application queue, and the determining module is specifically configured to:
匹配子模块,用于将该目标应用标识与该应用标识进行匹配;a matching submodule, configured to match the target application identifier with the application identifier;
若匹配成功,则将该匹配成功的应用标识对应的应用队列作为第一目标队列;If the matching is successful, the application queue corresponding to the successfully matched application identifier is used as the first target queue;
若匹配失败,则在该应用队列库中存储该目标应用标识,并创建一个与该目标应用标识对应的空应用队列,作为第一目标队列。If the matching fails, the target application identifier is stored in the application queue library, and an empty application queue corresponding to the target application identifier is created as the first target queue.
本实施例中,该应用队列库中已存储的应用队列和应用标识是关联存储的,比如可以将应用标识作为键(Key),将应用队列作为该键的值(Value)进行关联。电子设备可以提前建立每个应用的应用队列,也可以在应用首次启动时才建立对应应用队列。当应用首次启动才创建对应应用队列时,若应用队列库中不存在当前前台应用的应用队列,可以根据当前前台应用的应用标识建立一个空的先入先出队列,作为当前前台应用的应用队列。In this embodiment, the application queue and the application identifier stored in the application queue library are stored in association. For example, the application identifier may be used as a key, and the application queue is associated with the value of the key. The electronic device can establish an application queue for each application in advance, or can establish a corresponding application queue when the application is first started. If the application queue is created when the application is started for the first time, if there is no application queue of the current foreground application in the application queue, an empty first-in first-out queue can be established according to the application identifier of the current foreground application, as the application queue of the current foreground application.
(3)第一更新模块30(3) First update module 30
第一更新模块30,用于根据该目标切换信息对该第一目标队列进行更新,以在该应用队列库中存储该应用信息。The first update module 30 is configured to update the first target queue according to the target switching information to store the application information in the application queue library.
例如,该第一更新模块30具体可以用于:For example, the first update module 30 can be specifically configured to:
在该第一目标队列的队尾存储该目标切换信息;Storing the target switching information at the end of the first target queue;
当该目标切换信息加入成功时,统计该第一目标队列中切换信息的数量,作为第一数量;When the target switching information is successfully added, the number of switching information in the first target queue is counted as the first quantity;
判断该第一数量是否大于第一预设阈值;Determining whether the first quantity is greater than a first preset threshold;
若是,则将该第一目标队列中排位最靠前的预设条数切换信息进行删除。If yes, the preset number of pieces of switching information in the first target queue is deleted.
本实施例中,对于先入先出的应用队列,每次获取到新的切换信息时,可以将该新的切换信息存储在相应应用队列的末尾。该第一预设阈值可以根据实际内存大小而定,实际内存越大,其第一预设阈值可以越大,比如该第一预设阈值可以为100。该预设条数可以是人为设定的数值,比如5。通常,由于高频使用应用(简称高频应用)切换至前台的次数比较多,故其对应的应用队列中存储的切换信息也应较多(也即队列长度较长),为避免高频应用的切换信息过多的占用系统内存,从而导致没有足够的内存存储低频应用的切换信息,可以限定每个应用队列的最大长度(第一预设阈值),也即每当有新的切换信息存储在对应应用队列中时,可以检测该应用队列的长度是否超过最大长度,若超过,则进行数据删减,考虑到距离当前时间越久远的数据参考价值越低,故可以将存储时间最久(也即排在应用队列前面)的单个或部分切换信息进行删除。In this embodiment, for the first-in first-out application queue, each time the new switching information is acquired, the new switching information may be stored at the end of the corresponding application queue. The first preset threshold may be determined according to the actual memory size. The larger the actual memory, the larger the first preset threshold may be. For example, the first preset threshold may be 100. The preset number can be an artificially set value, such as 5. Generally, since the frequency of high frequency application (referred to as high frequency application) is switched to the foreground more frequently, the switching information stored in the corresponding application queue should also be more (that is, the queue length is longer), in order to avoid high frequency application. Excessive switching information occupies system memory, resulting in insufficient memory to store switching information of low frequency applications, and can limit the maximum length of each application queue (first preset threshold), that is, whenever there is new switching information storage When the corresponding application queue is used, it can detect whether the length of the application queue exceeds the maximum length. If it exceeds, the data is deleted. Considering that the data reference value is longer than the current time, the storage time can be the longest ( That is, single or partial switching information that is listed in front of the application queue is deleted.
(4)第二更新模块40(4) Second update module 40
第二更新模块40,用于根据更新后的第一目标队列对该应用队列库进行更新。The second update module 40 is configured to update the application queue library according to the updated first target queue.
例如,请参见图6,该第二更新模块40具体可以包括统计子模块41、排序子模块42和更新子模块43,其中:For example, referring to FIG. 6, the second update module 40 may specifically include a statistics submodule 41, a sorting submodule 42, and an update submodule 43, where:
统计子模块41,用于统计每一应用队列中切换信息的数量,作为第二数量;The statistics sub-module 41 is configured to count the number of switching information in each application queue as the second quantity;
排序子模块42,用于按照该第二数量从大到小的顺序对该应用队列库中的应用队列进行排序,得到排序后队列库,并根据该第二数量计算总数量;The sorting sub-module 42 is configured to sort the application queues in the application queue library according to the second quantity from the largest to the smallest, obtain the sorted queue library, and calculate the total quantity according to the second quantity;
更新子模块43,用于根据该总数量对该排序后队列库进行更新。The update sub-module 43 is configured to update the sorted queue library according to the total number.
本实施例中,由于该应用队列库通常存储在电子设备的系统内存中,为避免内存空间占用过多,可以将数据量控制在一定规模内,也即每次存储了新的切换信息时,都需要检测该应用队列库中切换信息的总量,根据该总量来决定需不需要进行数据删减。In this embodiment, since the application queue library is usually stored in the system memory of the electronic device, in order to avoid excessive use of the memory space, the data amount may be controlled within a certain scale, that is, each time a new switching information is stored, It is necessary to detect the total amount of switching information in the application queue library, and according to the total amount, it is determined that data deletion is not required.
例如,该更新子模块43具体可以用于:For example, the update submodule 43 can be specifically used to:
判断该总数量是否大于第二预设阈值;Determining whether the total quantity is greater than a second preset threshold;
若是,则选取该排序后队列库中排位最靠前的应用队列,作为待更新队列;If yes, the application queue with the highest ranking in the ranked queue library is selected as the queue to be updated;
获取该待更新队列对应的第二数量,并根据预设比例和该待更新队列对应的第二数量确定目标数量;Obtaining a second quantity corresponding to the to-be-updated queue, and determining a target quantity according to a preset ratio and a second quantity corresponding to the to-be-updated queue;
删除该待更新队列中前目标数量条切换信息,以对该待更新队列进行更新。The previous target quantity bar switching information in the queue to be updated is deleted to update the to-be-updated queue.
本实施例中,该第二预设阈值和预设比例可以是人为设定的,比如该第二预设阈值可以是1000,该预设比例可以是10%。当应用队列库中切换信息的总量超过第二预设阈值时,可以按照使用频率从高到底的顺序依次对应用的切换信息进行删减,首次删减时,选取的通常是排序后队列库中第一位的应用队列。In this embodiment, the second preset threshold and the preset ratio may be manually set. For example, the second preset threshold may be 1000, and the preset ratio may be 10%. When the total amount of the switching information in the application queue library exceeds the second preset threshold, the switching information of the application may be sequentially deleted according to the frequency of use from the highest to the lowest. When the first deletion is performed, the queue after the sorting is usually selected. The first application queue in the middle.
进一步地,在删除该待更新队列中前目标数量条切换信息之后,该更新子模块43还可以用于:Further, after deleting the previous target quantity strip switching information in the to-be-updated queue, the update sub-module 43 can also be used to:
计算当前该总数量和目标数量之间的差值;Calculating the difference between the current total quantity and the target quantity;
判断该差值是否小于或等于第三预设阈值,该第二预设阈值大于第三预设阈值;Determining whether the difference is less than or equal to a third preset threshold, where the second preset threshold is greater than a third preset threshold;
若是,则将该排序后队列库中的下一应用队列作为待更新队列,将该差值作为总数量,并返回执行获取该待更新队列对应的第二数量的操作,直至所有应用队列更新完毕。If yes, the next application queue in the sorted queue library is used as the queue to be updated, and the difference is taken as the total quantity, and the operation of obtaining the second quantity corresponding to the queue to be updated is performed until all application queues are updated. .
本实施例中,该第三预设阈值可以是人为设定的一个最佳存储量,比如800。当每次对单个应用队列进行删减之后,该应用队列库中切换信息的总量都会发生变化,若每次检测的总量都超过最佳存储量,则需要继续选取下一应用队列进行删减,直到总量小于或等于最佳存储量时停止。In this embodiment, the third preset threshold may be an optimal storage amount manually set, such as 800. After the single application queue is deleted, the total amount of switching information in the application queue library changes. If the total amount of detection exceeds the optimal storage amount, the next application queue needs to be selected for deletion. Decrease until the total amount is less than or equal to the optimal storage amount.
此外,由于一般的电子设备都有掉电保护策略,也即系统内存中存储的数据在断电的情况下会自动清零,为避免断电后该应用队列库中存储的数据丢失,可以定期将其同步到外部存储设备中,也即,请参见图7,该信息存储装置还可以包括同步模块50,用于:In addition, since the general electronic device has a power-down protection strategy, that is, the data stored in the system memory is automatically cleared in the case of power failure, in order to avoid data loss stored in the application queue library after the power failure, it may be periodically Synchronizing it to an external storage device, that is, referring to FIG. 7, the information storage device may further include a synchronization module 50 for:
在该第二更新模块40根据更新后的第一目标队列对该应用队列库进行更新之后,获取同步存储指令;After the second update module 40 updates the application queue library according to the updated first target queue, acquiring a synchronous storage instruction;
根据该同步存储指令获取该应用队列库中的应用标识;Obtaining an application identifier in the application queue library according to the synchronous storage instruction;
对该应用标识进行加密,得到加密标识;Encrypting the application identifier to obtain an encrypted identifier;
根据该加密标识将相应应用队列中的切换信息存储在第二电子设备中。The switching information in the corresponding application queue is stored in the second electronic device according to the encrypted identifier.
本实施例中,该同步存储指令可以是在关机或者到达指定时间后自动生成的,具体的,电子设备可以设置一个定时器,该定时器可以每隔一定时长(比如一个小时)或接收到关机信息就触发生成该同步存储指令。该加密方法可以根据实际需求而定,比如可以为AES(Advanced Encryption Standard,高级加密标准),其是一种对称加密算法,也即使用相同的密钥加密和解密数据。该第二电子设备主要指外部存储设备,比如存储服务器或者硬盘等。In this embodiment, the synchronous storage instruction may be automatically generated after the shutdown or the specified time is reached. Specifically, the electronic device may set a timer, and the timer may be shut down at a certain time (such as one hour) or received. The information triggers the generation of the synchronous store instruction. The encryption method may be determined according to actual needs, such as AES (Advanced Encryption Standard), which is a symmetric encryption algorithm, that is, encrypting and decrypting data using the same key. The second electronic device mainly refers to an external storage device, such as a storage server or a hard disk.
需要强调的是,由于应用的切换信息关系到用户的使用习惯,为避免外部存储设备在丢失或被盗时泄露用户隐私,可以在同步存储过程中对应用标识进行加密,当然,由于先入先出队列具有一定的数据结构,为避免存储过程中发生乱码,可以只在外部存储设备中存储加密标识和切换信息,具体的,电子设备可以在将加密标识写入外部存储设备之后,再写入回车作为行分割,然后依次写入对应应用队列中的切换信息,写完后同样写入回车作为行分割,接着开始写入下一个加密标识及其对应的切换信息,直至所有加密标识和切换信息写入完毕。It should be emphasized that, because the switching information of the application is related to the user's usage habits, in order to prevent the external storage device from leaking the user's privacy when it is lost or stolen, the application identifier may be encrypted in the synchronous storage process, of course, due to the first in first out. The queue has a certain data structure. To avoid garbled characters in the storage process, the encryption identifier and the switching information can be stored only in the external storage device. Specifically, the electronic device can write the encrypted identifier to the external storage device and then write it back. The car is divided into rows, and then written to the switching information in the corresponding application queue. After writing, the carriage return is also written as the line division, and then the next encryption identifier and its corresponding switching information are written, until all the encryption identifiers and switching are performed. The information has been written.
容易理解的是,由于每次断电后系统内存中的数据都会清零,故电子设备可以在开机后自动将外部存储存储设备中的数据同步到内存中,以便后续查询和使用,也即,该信息存储装置还可以包括第二获取模块60,用于:It is easy to understand that since the data in the system memory is cleared after each power failure, the electronic device can automatically synchronize the data in the external storage storage device into the memory after booting, so as to be subsequently queried and used, that is, The information storage device may further include a second obtaining module 60, configured to:
在该同步模块50根据该加密标识将相应应用队列中的切换信息存储在第二电子设备中之后,获取开机指令;After the synchronization module 50 stores the switching information in the corresponding application queue in the second electronic device according to the encryption identifier, acquiring a booting instruction;
根据该开机指令从该第二电子设备中获取加密标识、以及该加密标识对应的切换信息;And acquiring, according to the booting instruction, the encrypted identifier and the switching information corresponding to the encrypted identifier from the second electronic device;
对该加密标识进行解密,得到该应用标识;Decrypting the encrypted identifier to obtain the application identifier;
根据该应用标识和对应的切换信息建立该应用队列库。The application queue library is established according to the application identifier and the corresponding switching information.
本实施例中,对于AES加密算法,可以使用同样的秘钥对加密标识进行解密,还原得到应用标识,然后可以先建立一个与应用标识对应的空的先入先出队列,并在该空的先入先出队列中依次写入加密标识对应的切换信息,从而还原得到该应用队列。In this embodiment, for the AES encryption algorithm, the same key can be used to decrypt the encrypted identifier, and the application identifier is restored, and then an empty first in first out queue corresponding to the application identifier can be established first, and the empty first ingress is created. The switching information corresponding to the encrypted identifier is sequentially written in the first-out queue, thereby restoring the application queue.
具体实施时,以上各个单元可以作为独立的实体来实现,也可以进行任意组合,作为同一或若干个实体来实现,以上各个单元的具体实施可参见前面的方法实施例,在此不再赘述。In the specific implementation, the foregoing units may be implemented as a separate entity, or may be implemented in any combination, and may be implemented as the same or a plurality of entities. For the specific implementation of the foregoing, refer to the foregoing method embodiments, and details are not described herein.
由上述可知,本实施例提供的信息存储装置,应用于第一电子设备,通过第一获取模块10获取待存储的应用信息,该应用信息包括目标应用标识和目标切换信息,确定模块20根据该目标应用标识从已存储的应用队列库中确定第一目标队列,该应用队列库包括至 少一个应用队列,每一应用队列包括至少一条切换信息,第一更新模块30根据该目标切换信息对该第一目标队列进行更新,以在该应用队列库中存储该应用信息,第二更新模块40根据更新后的第一目标队列对该应用队列库进行更新,从而在应用信息的存储过程中,不仅能减少系统内存占用量,还可以较好地保证数据的全面性,方法简单,存储效果好。It can be seen from the above that the information storage device provided in this embodiment is applied to the first electronic device, and the application information to be stored is acquired by the first acquiring module 10, the application information includes the target application identifier and the target switching information, and the determining module 20 is configured according to the The target application identifier determines a first target queue from the stored application queue library, the application queue library includes at least one application queue, each application queue includes at least one piece of switching information, and the first update module 30 switches the information according to the target A target queue is updated to store the application information in the application queue library, and the second update module 40 updates the application queue library according to the updated first target queue, so that not only the application information storage process but also Reducing the system memory footprint can also ensure the comprehensiveness of the data, the method is simple, and the storage effect is good.
另外,本申请实施例还提供了一种电子设备,该电子设备可以是智能手机、平板电脑等设备。图8所示,电子设备900包括处理器901、存储器902、显示屏903以及控制电路904。其中,处理器901分别与存储器902、显示屏903、控制电路904电性连接。In addition, the embodiment of the present application further provides an electronic device, which may be a device such as a smart phone or a tablet computer. As shown in FIG. 8, the electronic device 900 includes a processor 901, a memory 902, a display screen 903, and a control circuit 904. The processor 901 is electrically connected to the memory 902, the display screen 903, and the control circuit 904, respectively.
处理器901是电子设备900的控制中心,利用各种接口和线路连接整个电子设备的各个部分,通过运行或加载存储在存储器902内的应用程序,以及调用存储在存储器902内的数据,执行电子设备的各种功能和处理数据,从而对电子设备进行整体监控。The processor 901 is a control center of the electronic device 900, and connects various parts of the entire electronic device using various interfaces and lines, executes the electronic by running or loading an application stored in the memory 902, and calling data stored in the memory 902. The various functions and processing data of the device enable overall monitoring of the electronic device.
在本实施例中,电子设备900中的处理器901会按照如下的步骤,将一个或一个以上的应用程序的进程对应的指令加载到存储器902中,并由处理器901来运行存储在存储器902中的应用程序,从而实现各种功能:In this embodiment, the processor 901 in the electronic device 900 loads the instructions corresponding to the process of one or more applications into the memory 902 according to the following steps, and is stored in the memory 902 by the processor 901. In the application, thus implementing various functions:
获取待存储的应用信息,该应用信息包括目标应用标识和目标切换信息;Obtaining application information to be stored, where the application information includes target application identifier and target switching information;
根据该目标应用标识从已存储的应用队列库中确定第一目标队列,该应用队列库包括至少一个应用队列,每一应用队列包括至少一条切换信息;Determining, according to the target application identifier, a first target queue from the stored application queue library, where the application queue library includes at least one application queue, and each application queue includes at least one switching information;
根据该目标切换信息对该第一目标队列进行更新,以在该应用队列库中存储该应用信息;Updating the first target queue according to the target switching information, to store the application information in the application queue library;
根据更新后的第一目标队列对该应用队列库进行更新。The application queue library is updated according to the updated first target queue.
进一步地,所述应用队列库还包括至少一个应用标识,每一应用标识对应一个应用队列,所述根据所述目标应用标识从已存储的应用队列库中确定第一目标队列,包括:Further, the application queue library further includes at least one application identifier, and each application identifier corresponds to one application queue, and the determining, according to the target application identifier, the first target queue from the stored application queue library, including:
将所述目标应用标识与所述应用标识进行匹配;Matching the target application identifier with the application identifier;
若匹配成功,则将所述匹配成功的应用标识对应的应用队列作为第一目标队列;If the matching is successful, the application queue corresponding to the successfully matched application identifier is used as the first target queue;
若匹配失败,则在所述应用队列库中存储所述目标应用标识,并创建一个与所述目标应用标识对应的空应用队列,作为第一目标队列。If the matching fails, the target application identifier is stored in the application queue library, and an empty application queue corresponding to the target application identifier is created as the first target queue.
进一步地,所述根据所述目标切换信息对所述第一目标队列进行更新,包括:Further, the updating, by the target switching information, the first target queue includes:
在所述第一目标队列的队尾存储所述目标切换信息;And storing the target switching information at a tail of the first target queue;
当所述目标切换信息加入成功时,统计所述第一目标队列中切换信息的数量,作为第一数量;When the target switching information is successfully added, the number of switching information in the first target queue is counted as the first quantity;
判断所述第一数量是否大于第一预设阈值;Determining whether the first quantity is greater than a first preset threshold;
若是,则将所述第一目标队列中排位最靠前的预设条数切换信息进行删除。If yes, the preset number of pieces of switching information in the first target queue is deleted.
进一步地,所述根据更新后的第一目标队列对所述应用队列库进行更新,包括:Further, the updating the application queue library according to the updated first target queue includes:
统计每一应用队列中切换信息的数量,作为第二数量;Counting the number of switching information in each application queue as the second quantity;
按照所述第二数量从大到小的顺序对所述应用队列库中的应用队列进行排序,得到排序后队列库,并根据所述第二数量计算总数量;Sorting application queues in the application queue library according to the second quantity from large to small, obtaining a sorted queue library, and calculating a total quantity according to the second quantity;
根据所述总数量对所述排序后队列库进行更新。The sorted queue library is updated according to the total number.
进一步地,所述根据所述总数量对所述排序后队列库进行更新,包括:Further, the updating the sorted queue library according to the total quantity comprises:
判断所述总数量是否大于第二预设阈值;Determining whether the total quantity is greater than a second preset threshold;
若是,则选取所述排序后队列库中排位最靠前的应用队列,作为待更新队列;If yes, the application queue with the highest ranking in the ranked queue library is selected as the queue to be updated;
获取所述待更新队列对应的第二数量,并根据预设比例和所述待更新队列对应的第二数量确定目标数量;Obtaining a second quantity corresponding to the to-be-updated queue, and determining a target quantity according to a preset ratio and a second quantity corresponding to the to-be-updated queue;
删除所述待更新队列中前目标数量条切换信息,以对所述待更新队列进行更新。Deleting the previous target quantity bar switching information in the queue to be updated to update the to-be-updated queue.
进一步地,在删除所述待更新队列中前目标数量条切换信息之后,所述信息存储方法还包括:Further, after deleting the previous target quantity strip switching information in the queue to be updated, the information storage method further includes:
计算当前所述总数量和目标数量之间的差值;Calculating the difference between the current total quantity and the target quantity;
判断所述差值是否小于或等于第三预设阈值,所述第二预设阈值大于第三预设阈值;Determining whether the difference is less than or equal to a third preset threshold, where the second preset threshold is greater than a third preset threshold;
若否,则将所述排序后队列库中的下一应用队列作为待更新队列,将所述差值作为总数量,并返回执行获取所述待更新队列对应的第二数量的操作,直至所有应用队列更新完毕。If no, the next application queue in the sorted queue library is used as the queue to be updated, and the difference is used as the total number, and the operation is performed to obtain the second quantity corresponding to the queue to be updated until all The application queue is updated.
进一步地,在根据更新后的第一目标队列对所述应用队列库进行更新之后,所述信息存储方法还包括:Further, after updating the application queue library according to the updated first target queue, the information storage method further includes:
获取同步存储指令;Obtaining a synchronous storage instruction;
根据所述同步存储指令获取所述应用队列库中的应用标识;Obtaining an application identifier in the application queue library according to the synchronous storage instruction;
对所述应用标识进行加密,得到加密标识;Encrypting the application identifier to obtain an encrypted identifier;
根据所述加密标识将相应应用队列中的切换信息存储在第二电子设备中。The switching information in the corresponding application queue is stored in the second electronic device according to the encrypted identifier.
进一步地,所述获取同步存储指令,包括:Further, the acquiring the synchronous storage instruction includes:
检测所述第一电子设备是否接收到关机指令,或者是否到达指定时间;Detecting whether the first electronic device receives a shutdown command, or whether a specified time is reached;
若是,则生成同步存储指令。If so, a synchronous store instruction is generated.
进一步地,在根据所述加密标识将相应应用队列中的切换信息存储在第二电子设备中之后,所述信息存储方法还包括:Further, after the switching information in the corresponding application queue is stored in the second electronic device according to the encryption identifier, the information storage method further includes:
获取开机指令;Obtain a boot command;
根据所述开机指令从所述第二电子设备中获取加密标识、以及所述加密标识对应的切换信息;Acquiring an encrypted identifier and the switching information corresponding to the encrypted identifier from the second electronic device according to the booting instruction;
对所述加密标识进行解密,得到所述应用标识;Decrypting the encrypted identifier to obtain the application identifier;
根据所述应用标识和对应的切换信息建立所述应用队列库。And establishing the application queue library according to the application identifier and corresponding switching information.
存储器902可用于存储应用程序和数据。存储器902存储的应用程序中包含有可在处理器中执行的指令。应用程序可以组成各种功能模块。处理器901通过运行存储在存储器902的应用程序,从而执行各种功能应用以及数据处理。 Memory 902 can be used to store applications and data. The application stored in the memory 902 contains instructions executable in the processor. Applications can form various functional modules. The processor 901 executes various functional applications and data processing by running an application stored in the memory 902.
显示屏903可用于显示由用户输入的信息或提供给用户的信息以及终端的各种图形用户接口,这些图形用户接口可以由图像、文本、图标、视频和其任意组合来构成。The display screen 903 can be used to display information entered by the user or information provided to the user as well as various graphical user interfaces of the terminal, which can be composed of images, text, icons, video, and any combination thereof.
控制电路904与显示屏903电性连接,用于控制显示屏903显示信息。The control circuit 904 is electrically connected to the display screen 903 for controlling the display screen 903 to display information.
在一些实施例中,如图8所示,电子设备900还包括:射频电路905、输入单元906、音频电路907、传感器908以及电源909。其中,处理器901分别与射频电路905、输入单元906、音频电路907、传感器908以及电源909电性连接。In some embodiments, as shown in FIG. 8, the electronic device 900 further includes a radio frequency circuit 905, an input unit 906, an audio circuit 907, a sensor 908, and a power source 909. The processor 901 is electrically connected to the radio frequency circuit 905, the input unit 906, the audio circuit 907, the sensor 908, and the power source 909, respectively.
射频电路905用于收发射频信号,以通过无线通信与网络设备或其他电子设备建立无线通讯,与网络设备或其他电子设备之间收发信号。The radio frequency circuit 905 is used for transmitting and receiving radio frequency signals to establish wireless communication with network devices or other electronic devices through wireless communication, and to transmit and receive signals with network devices or other electronic devices.
输入单元906可用于接收输入的数字、字符信息或用户特征信息(例如指纹),以及产生与用户设置以及功能控制有关的键盘、鼠标、操作杆、光学或者轨迹球信号输入。其中,输入单元906可以包括指纹识别模组。The input unit 906 can be configured to receive input digits, character information, or user characteristic information (eg, fingerprints), and to generate keyboard, mouse, joystick, optical, or trackball signal inputs related to user settings and function controls. The input unit 906 can include a fingerprint identification module.
音频电路907可通过扬声器、传声器提供用户与终端之间的音频接口。The audio circuit 907 can provide an audio interface between the user and the terminal through a speaker and a microphone.
电子设备900还可以包括至少一种传感器908,比如光传感器、运动传感器以及其他传感器。具体地,光传感器可包括环境光传感器及接近传感器,其中,环境光传感器可根据环境光线的明暗来调节显示面板的亮度,接近传感器可在终端移动到耳边时,关闭显示面板和/或背光。作为运动传感器的一种,重力加速度传感器可检测各个方向上(一般为三轴)加速度的大小,静止时可检测出重力的大小及方向,可用于识别手机姿态的应用(比如横竖屏切换、相关游戏、磁力计姿态校准)、振动识别相关功能(比如计步器、敲击)等;至于终端还可配置的陀螺仪、气压计、湿度计、温度计、红外线传感器等其他传感器,在此不再赘述。 Electronic device 900 may also include at least one type of sensor 908, such as a light sensor, motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel according to the brightness of the ambient light, and the proximity sensor may close the display panel and/or the backlight when the terminal moves to the ear. . As a kind of motion sensor, the gravity acceleration sensor can detect the magnitude of acceleration in all directions (usually three axes). When it is stationary, it can detect the magnitude and direction of gravity. It can be used to identify the gesture of the mobile phone (such as horizontal and vertical screen switching, related Game, magnetometer attitude calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for the terminal can also be configured with gyroscopes, barometers, hygrometers, thermometers, infrared sensors and other sensors, no longer Narration.
电源909用于给电子设备900的各个部件供电。在一些实施例中,电源909可以通过电源管理系统与处理器901逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。 Power source 909 is used to power various components of electronic device 900. In some embodiments, the power supply 909 can be logically coupled to the processor 901 through a power management system to enable functions such as managing charging, discharging, and power management through the power management system.
尽管图8中未示出,电子设备900还可以包括摄像头、蓝牙模块等,在此不再赘述。Although not shown in FIG. 8, the electronic device 900 may further include a camera, a Bluetooth module, and the like, and details are not described herein again.
本领域普通技术人员可以理解,上述实施例的各种方法中的全部或部分步骤可以通过指令来完成,或通过指令控制相关的硬件来完成,该指令可以存储于一计算机可读存储介质中,并由处理器进行加载和执行。为此,本发明实施例提供一种存储介质,其中存储有多条指令,该指令能够被处理器进行加载,以执行本发明实施例所提供的任一种信息存储方法中的步骤。It will be understood by those skilled in the art that all or part of the steps of the various methods in the above embodiments may be completed by instructions or controlled by related hardware, which may be stored in a computer readable storage medium. And loaded and executed by the processor. To this end, an embodiment of the present invention provides a storage medium in which a plurality of instructions are stored, which can be loaded by a processor to perform the steps in any of the information storage methods provided by the embodiments of the present invention.
其中,该存储介质可以包括:只读存储器(ROM,Read Only Memory)、随机存取记忆体(RAM,Random Access Memory)、磁盘或光盘等。The storage medium may include: a read only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
由于该存储介质中所存储的指令,可以执行本发明实施例所提供的任一种信息存储方法中的步骤,因此,可以实现本发明实施例所提供的任一种信息存储方法所能实现的有益效果,详见前面的实施例,在此不再赘述。The steps in the information storage method provided in the embodiment of the present invention can be implemented by using the instructions stored in the storage medium. Therefore, any information storage method provided by the embodiment of the present invention can be implemented. For the beneficial effects, see the previous embodiments in detail, and details are not described herein again.
以上各个操作的具体实施可参见前面的实施例,在此不再赘述。For the specific implementation of the foregoing operations, refer to the foregoing embodiments, and details are not described herein again.
综上所述,虽然本申请已以优选实施例揭露如上,但上述优选实施例并非用以限制本申请,本领域的普通技术人员,在不脱离本申请的精神和范围内,均可作各种更动与润饰,因此本申请的保护范围以权利要求界定的范围为准。In the above, although the present application has been disclosed in the above preferred embodiments, the preferred embodiments are not intended to limit the application, and those skilled in the art can make various modifications without departing from the spirit and scope of the application. The invention is modified and retouched, and the scope of protection of the present application is determined by the scope defined by the claims.

Claims (20)

  1. 一种信息存储方法,应用于第一电子设备,其包括:An information storage method is applied to a first electronic device, including:
    获取待存储的应用信息,所述应用信息包括目标应用标识和目标切换信息;Obtaining application information to be stored, where the application information includes target application identifier and target switching information;
    根据所述目标应用标识从已存储的应用队列库中确定第一目标队列,所述应用队列库包括至少一个应用队列,每一应用队列包括至少一条切换信息;Determining, according to the target application identifier, a first target queue from the stored application queue library, where the application queue library includes at least one application queue, and each application queue includes at least one switching information;
    根据所述目标切换信息对所述第一目标队列进行更新,以在所述应用队列库中存储所述应用信息;Updating the first target queue according to the target switching information, to store the application information in the application queue library;
    根据更新后的第一目标队列对所述应用队列库进行更新。The application queue library is updated according to the updated first target queue.
  2. 根据权利要求1所述的信息存储方法,其中,所述应用队列库还包括至少一个应用标识,每一应用标识对应一个应用队列,所述根据所述目标应用标识从已存储的应用队列库中确定第一目标队列,包括:The information storage method according to claim 1, wherein the application queue library further comprises at least one application identifier, each application identifier corresponding to an application queue, and the target application identifier is from the stored application queue library according to the target application identifier Determine the first target queue, including:
    将所述目标应用标识与所述应用标识进行匹配;Matching the target application identifier with the application identifier;
    若匹配成功,则将所述匹配成功的应用标识对应的应用队列作为第一目标队列;If the matching is successful, the application queue corresponding to the successfully matched application identifier is used as the first target queue;
    若匹配失败,则在所述应用队列库中存储所述目标应用标识,并创建一个与所述目标应用标识对应的空应用队列,作为第一目标队列。If the matching fails, the target application identifier is stored in the application queue library, and an empty application queue corresponding to the target application identifier is created as the first target queue.
  3. 根据权利要求1所述的信息存储方法,其中,所述根据所述目标切换信息对所述第一目标队列进行更新,包括:The information storage method according to claim 1, wherein the updating the first target queue according to the target switching information comprises:
    在所述第一目标队列的队尾存储所述目标切换信息;And storing the target switching information at a tail of the first target queue;
    当所述目标切换信息加入成功时,统计所述第一目标队列中切换信息的数量,作为第一数量;When the target switching information is successfully added, the number of switching information in the first target queue is counted as the first quantity;
    判断所述第一数量是否大于第一预设阈值;Determining whether the first quantity is greater than a first preset threshold;
    若是,则将所述第一目标队列中排位最靠前的预设条数切换信息进行删除。If yes, the preset number of pieces of switching information in the first target queue is deleted.
  4. 根据权利要求1所述的信息存储方法,其中,所述根据更新后的第一目标队列对所述应用队列库进行更新,包括:The information storage method according to claim 1, wherein the updating the application queue library according to the updated first target queue comprises:
    统计每一应用队列中切换信息的数量,作为第二数量;Counting the number of switching information in each application queue as the second quantity;
    按照所述第二数量从大到小的顺序对所述应用队列库中的应用队列进行排序,得到排序后队列库,并根据所述第二数量计算总数量;Sorting application queues in the application queue library according to the second quantity from large to small, obtaining a sorted queue library, and calculating a total quantity according to the second quantity;
    根据所述总数量对所述排序后队列库进行更新。The sorted queue library is updated according to the total number.
  5. 根据权利要求4所述的信息存储方法,其中,所述根据所述总数量对所述排序后队列库进行更新,包括:The information storage method according to claim 4, wherein the updating the sorted queue library according to the total number comprises:
    判断所述总数量是否大于第二预设阈值;Determining whether the total quantity is greater than a second preset threshold;
    若是,则选取所述排序后队列库中排位最靠前的应用队列,作为待更新队列;If yes, the application queue with the highest ranking in the ranked queue library is selected as the queue to be updated;
    获取所述待更新队列对应的第二数量,并根据预设比例和所述待更新队列对应的第二数量确定目标数量;Obtaining a second quantity corresponding to the to-be-updated queue, and determining a target quantity according to a preset ratio and a second quantity corresponding to the to-be-updated queue;
    删除所述待更新队列中前目标数量条切换信息,以对所述待更新队列进行更新。Deleting the previous target quantity bar switching information in the queue to be updated to update the to-be-updated queue.
  6. 根据权利要求5所述的信息存储方法,其中,在删除所述待更新队列中前目标数量条切换信息之后,还包括:The information storage method according to claim 5, further comprising: after deleting the previous target number of pieces of switching information in the queue to be updated,
    计算当前所述总数量和目标数量之间的差值;Calculating the difference between the current total quantity and the target quantity;
    判断所述差值是否小于或等于第三预设阈值,所述第二预设阈值大于第三预设阈值;Determining whether the difference is less than or equal to a third preset threshold, where the second preset threshold is greater than a third preset threshold;
    若否,则将所述排序后队列库中的下一应用队列作为待更新队列,将所述差值作为总数量,并返回执行获取所述待更新队列对应的第二数量的操作,直至所有应用队列更新完毕。If no, the next application queue in the sorted queue library is used as the queue to be updated, and the difference is used as the total number, and the operation is performed to obtain the second quantity corresponding to the queue to be updated until all The application queue is updated.
  7. 根据权利要求1-6中任意一项所述的信息存储方法,其中,在根据更新后的第一目标队列对所述应用队列库进行更新之后,还包括:The information storage method according to any one of claims 1 to 6, further comprising: after updating the application queue library according to the updated first target queue, further comprising:
    获取同步存储指令;Obtaining a synchronous storage instruction;
    根据所述同步存储指令获取所述应用队列库中的应用标识;Obtaining an application identifier in the application queue library according to the synchronous storage instruction;
    对所述应用标识进行加密,得到加密标识;Encrypting the application identifier to obtain an encrypted identifier;
    根据所述加密标识将相应应用队列中的切换信息存储在第二电子设备中。The switching information in the corresponding application queue is stored in the second electronic device according to the encrypted identifier.
  8. 根据权利要求7所述的信息存储方法,其中,所述获取同步存储指令,包括:The information storage method according to claim 7, wherein the obtaining the synchronous storage instruction comprises:
    检测所述第一电子设备是否接收到关机指令,或者是否到达指定时间;Detecting whether the first electronic device receives a shutdown command, or whether a specified time is reached;
    若是,则生成同步存储指令。If so, a synchronous store instruction is generated.
  9. 根据权利要求7所述的信息存储方法,其中,在根据所述加密标识将相应应用队列中的切换信息存储在第二电子设备中之后,还包括:The information storage method according to claim 7, wherein after the switching information in the corresponding application queue is stored in the second electronic device according to the encrypted identifier, the method further includes:
    获取开机指令;Obtain a boot command;
    根据所述开机指令从所述第二电子设备中获取加密标识、以及所述加密标识对应的切换信息;Acquiring an encrypted identifier and the switching information corresponding to the encrypted identifier from the second electronic device according to the booting instruction;
    对所述加密标识进行解密,得到所述应用标识;Decrypting the encrypted identifier to obtain the application identifier;
    根据所述应用标识和对应的切换信息建立所述应用队列库。And establishing the application queue library according to the application identifier and corresponding switching information.
  10. 一种信息存储装置,应用于第一电子设备,其包括:An information storage device is applied to a first electronic device, including:
    获取模块,用于获取待存储的应用信息,所述应用信息包括目标应用标识和目标切换信息;An acquiring module, configured to acquire application information to be stored, where the application information includes target application identifier and target switching information;
    确定模块,用于根据所述目标应用标识从已存储的应用队列库中确定第一目标队列,所述应用队列库包括至少一个应用队列,每一应用队列包括至少一条切换信息;a determining module, configured to determine, according to the target application identifier, a first target queue from the stored application queue library, where the application queue library includes at least one application queue, and each application queue includes at least one switching information;
    第一更新模块,用于根据所述目标切换信息对所述第一目标队列进行更新,以在所述应用队列库中存储所述应用信息;a first update module, configured to update the first target queue according to the target switching information, to store the application information in the application queue library;
    第二更新模块,用于根据更新后的第一目标队列对所述应用队列库进行更新。And a second update module, configured to update the application queue library according to the updated first target queue.
  11. 根据权利要求10所述的信息存储装置,其中,所述应用队列库还包括至少一个应用标识,每一应用标识对应一个应用队列,所述确定模块具体用于:The information storage device of claim 10, wherein the application queue library further comprises at least one application identifier, each application identifier corresponding to an application queue, and the determining module is specifically configured to:
    匹配子模块,用于将所述目标应用标识与所述应用标识进行匹配;a matching submodule, configured to match the target application identifier with the application identifier;
    若匹配成功,则将所述匹配成功的应用标识对应的应用队列作为第一目标队列;If the matching is successful, the application queue corresponding to the successfully matched application identifier is used as the first target queue;
    若匹配失败,则在所述应用队列库中存储所述目标应用标识,并创建一个与所述目标应用标识对应的空应用队列,作为第一目标队列。If the matching fails, the target application identifier is stored in the application queue library, and an empty application queue corresponding to the target application identifier is created as the first target queue.
  12. 根据权利要求10所述的信息存储装置,其中,所述第一更新模块具体用于:The information storage device of claim 10, wherein the first update module is specifically configured to:
    在所述第一目标队列的队尾存储所述目标切换信息;And storing the target switching information at a tail of the first target queue;
    当所述目标切换信息加入成功时,统计所述第一目标队列中切换信息的数量,作为第一数量;When the target switching information is successfully added, the number of switching information in the first target queue is counted as the first quantity;
    判断所述第一数量是否大于第一预设阈值;Determining whether the first quantity is greater than a first preset threshold;
    若是,则将所述第一目标队列中排位最靠前的预设条数切换信息进行删除。If yes, the preset number of pieces of switching information in the first target queue is deleted.
  13. 根据权利要求10所述的信息存储装置,其中,所述第二更新模块具体包括:The information storage device of claim 10, wherein the second update module comprises:
    统计子模块,用于统计每一应用队列中切换信息的数量,作为第二数量;a statistics sub-module, configured to count the number of switching information in each application queue as a second quantity;
    排序子模块,用于按照所述第二数量从大到小的顺序对所述应用队列库中的应用队列进行排序,得到排序后队列库,并根据所述第二数量计算总数量;a sorting sub-module, configured to sort the application queues in the application queue library according to the second quantity from large to small, obtain a sorted queue library, and calculate a total quantity according to the second quantity;
    更新子模块,用于根据所述总数量对所述排序后队列库进行更新。An update submodule is configured to update the sorted queue library according to the total number.
  14. 根据权利要求13所述的信息存储装置,其中,所述更新子模块具体用于:The information storage device according to claim 13, wherein the update submodule is specifically configured to:
    判断所述总数量是否大于第二预设阈值;Determining whether the total quantity is greater than a second preset threshold;
    若是,则选取所述排序后队列库中排位最靠前的应用队列,作为待更新队列;If yes, the application queue with the highest ranking in the ranked queue library is selected as the queue to be updated;
    获取所述待更新队列对应的第二数量,并根据预设比例和所述待更新队列对应的第二数量确定目标数量;Obtaining a second quantity corresponding to the to-be-updated queue, and determining a target quantity according to a preset ratio and a second quantity corresponding to the to-be-updated queue;
    删除所述待更新队列中前目标数量条切换信息,以对所述待更新队列进行更新。Deleting the previous target quantity bar switching information in the queue to be updated to update the to-be-updated queue.
  15. 根据权利要求14所述的信息存储装置,其中,在删除所述待更新队列中前目标数量条切换信息之后,所述更新子模块还用于:The information storage device according to claim 14, wherein the update sub-module is further configured to: after deleting the previous target number of pieces of switching information in the queue to be updated;
    计算当前所述总数量和目标数量之间的差值;Calculating the difference between the current total quantity and the target quantity;
    判断所述差值是否小于或等于第三预设阈值,所述第二预设阈值大于第三预设阈值;Determining whether the difference is less than or equal to a third preset threshold, where the second preset threshold is greater than a third preset threshold;
    若否,则将所述排序后队列库中的下一应用队列作为待更新队列,将所述差值作为总数量,并返回执行获取所述待更新队列对应的第二数量的操作,直至所有应用队列更新完毕。If no, the next application queue in the sorted queue library is used as the queue to be updated, and the difference is used as the total number, and the operation is performed to obtain the second quantity corresponding to the queue to be updated until all The application queue is updated.
  16. 根据权利要求10-15中任意一项所述的信息存储装置,其还包括同步模块,用于:The information storage device according to any one of claims 10-15, further comprising a synchronization module, configured to:
    在根据更新后的第一目标队列对所述应用队列库进行更新后,获取同步存储指令;After updating the application queue library according to the updated first target queue, acquiring a synchronous storage instruction;
    根据所述同步存储指令获取所述应用队列库中的应用标识;Obtaining an application identifier in the application queue library according to the synchronous storage instruction;
    对所述应用标识进行加密,得到加密标识;Encrypting the application identifier to obtain an encrypted identifier;
    根据所述加密标识将相应应用队列中的切换信息存储在第二电子设备中。The switching information in the corresponding application queue is stored in the second electronic device according to the encrypted identifier.
  17. 根据权利要求16所述的信息存储装置,其中,所述同步模块具体用于:The information storage device according to claim 16, wherein the synchronization module is specifically configured to:
    检测所述第一电子设备是否接收到关机指令,或者是否到达指定时间;Detecting whether the first electronic device receives a shutdown command, or whether a specified time is reached;
    若是,则生成同步存储指令。If so, a synchronous store instruction is generated.
  18. 根据权利要求16所述的信息存储装置,其还包括第二获取模块,用于:The information storage device of claim 16, further comprising a second acquisition module, configured to:
    在根据所述加密标识将相应应用队列中的切换信息存储在第二电子设备中后,获取开机指令;After the switching information in the corresponding application queue is stored in the second electronic device according to the encrypted identifier, obtaining a booting instruction;
    根据所述开机指令从所述第二电子设备中获取加密标识、以及所述加密标识对应的切换信息;Acquiring an encrypted identifier and the switching information corresponding to the encrypted identifier from the second electronic device according to the booting instruction;
    对所述加密标识进行解密,得到所述应用标识;Decrypting the encrypted identifier to obtain the application identifier;
    根据所述应用标识和对应的切换信息建立所述应用队列库。And establishing the application queue library according to the application identifier and corresponding switching information.
  19. 一种存储介质,其中,所述存储介质中存储有多条指令,所述指令适于由处理器加载以执行权利要求1至9中任一项所述的信息存储方法。A storage medium, wherein the storage medium stores a plurality of instructions, the instructions being adapted to be loaded by a processor to perform the information storage method of any one of claims 1 to 9.
  20. 一种电子设备,其包括处理器和存储器,所述处理器与所述存储器电性连接,所述存储器用于存储指令和数据,所述处理器用于执行权利要求1至9中任一项所述的信息存储方法中的步骤。An electronic device comprising a processor and a memory, the processor being electrically connected to the memory, the memory for storing instructions and data, the processor for performing any one of claims 1 to The steps in the information storage method described.
PCT/CN2018/115268 2017-11-14 2018-11-13 Information storage method and apparatus, storage medium, and electronic device WO2019096134A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201711124553.8 2017-11-14
CN201711124553.8A CN107943562B (en) 2017-11-14 2017-11-14 Information storage method, information storage device, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
WO2019096134A1 true WO2019096134A1 (en) 2019-05-23

Family

ID=61932094

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/115268 WO2019096134A1 (en) 2017-11-14 2018-11-13 Information storage method and apparatus, storage medium, and electronic device

Country Status (2)

Country Link
CN (1) CN107943562B (en)
WO (1) WO2019096134A1 (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107943562B (en) * 2017-11-14 2020-09-08 Oppo广东移动通信有限公司 Information storage method, information storage device, storage medium and electronic equipment
CN109445915A (en) * 2018-09-27 2019-03-08 努比亚技术有限公司 Task processing method, server and terminal
CN111338810A (en) * 2018-12-19 2020-06-26 北京京东尚科信息技术有限公司 Method and apparatus for storing information
CN111274010B (en) * 2020-01-14 2024-01-16 Oppo广东移动通信有限公司 Data control method, device, electronic equipment and storage medium
CN112307518B (en) * 2020-10-16 2024-06-11 神州融安科技(北京)有限公司 Signature information processing method, signature information display method, signature information processing device, signature information display device, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101655808A (en) * 2009-09-07 2010-02-24 宇龙计算机通信科技(深圳)有限公司 Application program management method and mobile communication terminal
CN103077075A (en) * 2012-12-27 2013-05-01 东莞宇龙通信科技有限公司 Method and terminal for displaying backgrounder application
CN106201688A (en) * 2016-07-06 2016-12-07 青岛海信移动通信技术股份有限公司 The control method of a kind of application program and device
CN107943562A (en) * 2017-11-14 2018-04-20 广东欧珀移动通信有限公司 Information storage means, device, storage medium and electronic equipment

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101102281B (en) * 2007-08-16 2010-04-07 中兴通讯股份有限公司 Data processing method for reporting a large number of data in mobile communication system
US8452901B1 (en) * 2011-12-30 2013-05-28 Emc Corporation Ordered kernel queue for multipathing events
CN105320577B (en) * 2014-06-11 2018-09-04 中国移动通信集团公司 A kind of data backup and resume method, system and device
US9910755B2 (en) * 2015-06-26 2018-03-06 Amazon Technologies, Inc. Retrieval of authoritative measurement data from in-memory datastores

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101655808A (en) * 2009-09-07 2010-02-24 宇龙计算机通信科技(深圳)有限公司 Application program management method and mobile communication terminal
CN103077075A (en) * 2012-12-27 2013-05-01 东莞宇龙通信科技有限公司 Method and terminal for displaying backgrounder application
CN106201688A (en) * 2016-07-06 2016-12-07 青岛海信移动通信技术股份有限公司 The control method of a kind of application program and device
CN107943562A (en) * 2017-11-14 2018-04-20 广东欧珀移动通信有限公司 Information storage means, device, storage medium and electronic equipment

Also Published As

Publication number Publication date
CN107943562B (en) 2020-09-08
CN107943562A (en) 2018-04-20

Similar Documents

Publication Publication Date Title
WO2019096134A1 (en) Information storage method and apparatus, storage medium, and electronic device
EP3382994B1 (en) Method and apparatus for updating data
EP3451193B1 (en) Electronic device and file data journaling method of electronic device
CN106357808B (en) A kind of method of data synchronization and device
WO2019024641A1 (en) Data synchronization method and apparatus, storage medium and electronic device
US10922193B2 (en) Data backup method, storage medium, and terminal
CN109714476B (en) Data processing method and device, mobile terminal and storage medium
US10789171B2 (en) Information processing method and device, and method and device for displaying dynamic information
WO2019062462A1 (en) Application control method and apparatus, storage medium and electronic device
WO2019024646A1 (en) Application management and control method, apparatus, and electronic device
CN107908492B (en) Black screen detection method, mobile terminal and computer readable storage medium
US10970522B2 (en) Data processing method, electronic device, and computer-readable storage medium
CN107832191B (en) Black screen detection method, mobile terminal and computer readable storage medium
CN107872367B (en) Black screen detection method, mobile terminal and computer readable storage medium
CN111459410B (en) Memory space allocation method and device, electronic equipment and storage medium
CN106844057B (en) Data processing method and device and mobile terminal
CN107688498B (en) Application program processing method and device, computer equipment and storage medium
CN109992369B (en) Application program processing method and device, electronic equipment and computer readable storage medium
CN113098781B (en) Session list processing method, device, server and storage medium
CN109463002B (en) Method, device and equipment for storing data into queue
CN113918757A (en) Application recommendation method and device, electronic equipment and storage medium
CN107766210B (en) Black screen detection method, mobile terminal and computer readable storage medium
US10602001B2 (en) Method for identifying data usage and electronic device implementing the same
CN111143580A (en) Multimedia data storage method and device, storage medium and electronic equipment
CN115086235B (en) Network congestion detection method, device, electronic equipment and storage medium

Legal Events

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

Ref document number: 18878993

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18878993

Country of ref document: EP

Kind code of ref document: A1