CN114357302A - A method and device for storing information - Google Patents
A method and device for storing information Download PDFInfo
- Publication number
- CN114357302A CN114357302A CN202111677190.7A CN202111677190A CN114357302A CN 114357302 A CN114357302 A CN 114357302A CN 202111677190 A CN202111677190 A CN 202111677190A CN 114357302 A CN114357302 A CN 114357302A
- Authority
- CN
- China
- Prior art keywords
- browsing information
- bucket
- user
- information
- array
- Prior art date
- Legal status (The legal status 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 status listed.)
- Granted
Links
Images
Landscapes
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
- Information Transfer Between Computers (AREA)
Abstract
Description
技术领域technical field
本发明涉及信息存储技术领域,尤其涉及一种信息存储的方法及装置。The present invention relates to the technical field of information storage, and in particular, to a method and device for information storage.
背景技术Background technique
在信息爆炸的互联网时代,如何吸引用户关注和浏览对于互联网公司的重要性是不言而喻的,而大多数互联网公司会针对用户的爱好推荐相关信息,并在推荐相关信息的过程中,排除用户最近一段时间浏览过的信息,以吸引用户浏览。In the Internet era of information explosion, the importance of attracting users' attention and browsing is self-evident for Internet companies, and most Internet companies recommend relevant information for users' hobbies, and exclude relevant information in the process of recommending relevant information. Information that the user has browsed in the recent period to attract users to browse.
目前,在推荐相关信息时,会预先存储用户浏览过的信息以及浏览的时间,以在推荐的相关信息中查询是否存在最近一段时间浏览过的信息,进而排除最近一段时间浏览过的信息,而这需要同时存储浏览过的信息和浏览的时间,占用大量的存储空间,提高了存储成本。At present, when recommending relevant information, the information that the user has browsed and the browsing time will be stored in advance, so as to check whether there is information that has been browsed in the recent period of time in the recommended related information, and then exclude the information that has been browsed in the recent period of time. This requires storing the browsed information and the browsing time at the same time, occupying a large amount of storage space and increasing the storage cost.
发明内容SUMMARY OF THE INVENTION
本发明所要解决的技术问题在于,提供一种信息存储的方法及装置,能够仅对用户浏览信息进行对应存储,节省了大量的存储空间,减少了存储成本。The technical problem to be solved by the present invention is to provide an information storage method and device, which can only store user browsing information correspondingly, save a lot of storage space and reduce storage cost.
为了解决上述技术问题,本发明第一方面公开了一种信息存储的方法,所述方法包括:In order to solve the above technical problems, a first aspect of the present invention discloses a method for storing information, the method comprising:
确定已创建的至少一个桶数组,并确定每个所述桶数组的创建时刻;每个所述桶数组用于存储与其对应的存储时段内的用户已浏览信息,任一所述桶数组对应的存储时段是根据该桶数组的创建时刻以及在该桶数组创建之后创建的第一个桶数组的创建时刻确定出的;Determine at least one bucket array that has been created, and determine the creation time of each bucket array; each bucket array is used to store the user's browsing information in its corresponding storage period, and any bucket array corresponding to The storage period is determined according to the creation time of the bucket array and the creation time of the first bucket array created after the bucket array is created;
获取目标用户已浏览的至少一个用户浏览信息,并确定每个所述用户浏览信息的浏览时刻;Obtain at least one user browsing information that the target user has browsed, and determine the browsing time of each user browsing information;
根据每个所述用户浏览信息的浏览时刻以及每个所述桶数组对应的存储时段,将每个所述用户浏览信息对应存储在确定出的所述桶数组。According to the browsing time of each user browsing information and the storage period corresponding to each bucket array, each of the user browsing information is correspondingly stored in the determined bucket array.
作为一种可选的实施方式,在本发明第一方面中,所述根据每个所述用户浏览信息的浏览时刻以及每个所述桶数组对应的存储时段,将每个所述用户浏览信息对应存储在确定出的所述桶数组,包括:As an optional implementation manner, in the first aspect of the present invention, according to the browsing time of each user browsing information and the storage period corresponding to each bucket array, the Correspondingly stored in the determined bucket array, including:
对于每个所述用户浏览信息,根据每个所述桶数组对应的存储时段,从所有所述桶数组对应的存储时段中确定该用户浏览信息的浏览时刻所处的目标存储时段,并将所述目标存储时段对应的目标桶数组确定为与该用户浏览信息对应的目标桶数组;For each user browsing information, according to the storage period corresponding to each bucket array, determine the target storage period at which the browsing moment of the user browsing information is located from the storage periods corresponding to all the bucket arrays, and assign the The target bucket array corresponding to the target storage period is determined as the target bucket array corresponding to the user browsing information;
对于每个所述用户浏览信息,将该用户浏览信息存储至与该用户浏览信息对应的目标桶数组。For each user browsing information, the user browsing information is stored in a target bucket array corresponding to the user browsing information.
作为一种可选的实施方式,在本发明第一方面中,所述方法还包括:As an optional implementation manner, in the first aspect of the present invention, the method further includes:
确定待遍历的目标浏览信息唯一对应的标识信息;Determine the identification information uniquely corresponding to the target browsing information to be traversed;
从当前存在的所有所述桶数组中,按照创建时长由长到短的顺序依次从当前存在的所有所述桶数组中遍历所述标识信息对应的所述目标浏览信息,直至遍历到所述目标浏览信息或者当前存在的所有所述桶数组被遍历完毕;From all the bucket arrays that currently exist, traverse the target browsing information corresponding to the identification information from all the bucket arrays currently existing in the order of creation duration from long to short, until the target is traversed Browsing information or all currently existing bucket arrays have been traversed;
其中,所述目标浏览信息为待查询用户浏览信息或者待删除用户浏览信息。The target browsing information is the browsing information of the user to be queried or the browsing information of the user to be deleted.
作为一种可选的实施方式,在本发明第一方面中,所述对于每个所述用户浏览信息,将该用户浏览信息存储在与该用户浏览信息对应的目标桶数组,包括:As an optional implementation manner, in the first aspect of the present invention, for each user browsing information, storing the user browsing information in a target bucket array corresponding to the user browsing information, including:
对于每个所述用户浏览信息,确定该用户浏览信息对应的标识信息,并通过预置的散列函数对该用户浏览信息对应的标识信息进行散列,得到该用户浏览信息对应的散列值,以及确定该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置;For each user browsing information, the identification information corresponding to the user browsing information is determined, and the identification information corresponding to the user browsing information is hashed by a preset hash function to obtain a hash value corresponding to the user browsing information , and determine the storage location of the hash value corresponding to the user browsing information in the target bucket array corresponding to the user browsing information;
对于每个所述用户浏览信息,将该用户浏览信息对应的散列值存储在与该用户浏览信息对应的目标桶数组中的存储位置。For each of the user browsing information, the hash value corresponding to the user browsing information is stored in a storage location in the target bucket array corresponding to the user browsing information.
作为一种可选的实施方式,在本发明第一方面中,所述桶数组包括至少两个候选桶,所述对于每个所述用户浏览信息,确定该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置,包括:As an optional implementation manner, in the first aspect of the present invention, the bucket array includes at least two candidate buckets, and for each user browsing information, it is determined that the hash value corresponding to the user browsing information is in The storage location in the target bucket array corresponding to the user's browsing information, including:
对于每个所述用户浏览信息,通过预置的散列函数确定该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置,以及确定该用户浏览信息对应的散列值在对应的目标桶数组中的第二候选桶的存储位置;For each user browsing information, the storage location of the first candidate bucket in the corresponding target bucket array of the hash value corresponding to the user browsing information is determined by a preset hash function, and the corresponding hash value of the user browsing information is determined. The storage location of the hash value in the second candidate bucket in the corresponding target bucket array;
对于每个所述用户浏览信息,根据该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置的占用情况以及该用户浏览信息对应的散列值在对应的目标桶数组中的第二候选桶的存储位置的占用情况,确定该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置。For each user browsing information, according to the occupancy of the storage location of the first candidate bucket in the corresponding target bucket array and the hash value corresponding to the user browsing information in the corresponding The occupancy of the storage location of the second candidate bucket in the target bucket array determines the storage location of the hash value corresponding to the user browsing information in the target bucket array corresponding to the user browsing information.
作为一种可选的实施方式,在本发明第一方面中,所述对于每个所述用户浏览信息,根据该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置的占用情况以及该用户浏览信息对应的散列值在对应的目标桶数组中的第二候选桶的存储位置的占用情况,确定该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置,包括:As an optional implementation manner, in the first aspect of the present invention, for each user browsing information, according to the hash value corresponding to the user browsing information, the first candidate bucket in the corresponding target bucket array The occupancy of the storage location of the user's browsing information and the occupancy of the storage location of the second candidate bucket in the corresponding target bucket array of the hash value corresponding to the user's browsing information, determine that the hash value corresponding to the user's browsing information is the same as the user's browsing information. The storage location in the target bucket array corresponding to the information, including:
对于每个所述用户浏览信息,检测该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置是否被占用,并在检测到该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置没有被占用时,将该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置确定为该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置;For each user browsing information, it is detected whether the storage location of the first candidate bucket in the corresponding target bucket array of the hash value corresponding to the user browsing information is occupied, and when the hash value corresponding to the user browsing information is detected When the storage location of the first candidate bucket in the corresponding target bucket array is not occupied, the storage location of the first candidate bucket in the corresponding target bucket array of the hash value corresponding to the user's browsing information is determined as the user The storage location of the hash value corresponding to the browsing information in the target bucket array corresponding to the browsing information of the user;
对于每个所述用户浏览信息,在检测到该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置被占用时,将该用户浏览信息对应的散列值在对应的目标桶数组中的第二候选桶的存储位置确定为该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置。For each user browsing information, when it is detected that the hash value corresponding to the user browsing information is occupied in the storage location of the first candidate bucket in the corresponding target bucket array, the hash value corresponding to the user browsing information is occupied. The storage location of the second candidate bucket in the corresponding target bucket array is determined as the storage location of the hash value corresponding to the user browsing information in the target bucket array corresponding to the user browsing information.
作为一种可选的实施方式,在本发明第一方面中,所述方法还包括:As an optional implementation manner, in the first aspect of the present invention, the method further includes:
根据当前时刻和每个所述桶数组的创建时刻,确定每个所述桶数组的创建时长;Determine the creation duration of each of the bucket arrays according to the current moment and the creation moment of each of the bucket arrays;
对所有所述桶数组的创建时长中的最短创建时长和预置的第二预设时长进行比较,并所述最短创建时长大于所述第二预设时长时,创建新的桶数组并将待插入浏览信息存储至所述新的桶数组;The shortest creation duration among the creation durations of all the bucket arrays is compared with the preset second preset duration, and when the shortest creation duration is greater than the second preset duration, a new bucket array is created and will be inserting browsing information into the new bucket array;
对于每个所述桶数组,对该桶数组的创建时长和预置的第三预设时长进行比较,并在该桶数组的创建时长大于所述第三预设时长时,从所有所述桶数组中删除该桶数组。For each bucket array, the creation duration of the bucket array is compared with a preset third preset duration, and when the creation duration of the bucket array is greater than the third preset duration Delete the bucket array from the array.
本发明第二方面公开了一种信息存储的装置,所述装置包括:A second aspect of the present invention discloses an information storage device, the device comprising:
确定模块,用于确定已创建的至少一个桶数组,并确定每个所述桶数组的创建时刻;每个所述桶数组用于存储与其对应的存储时段内的用户已浏览信息,任一所述桶数组对应的存储时段是根据该桶数组的创建时刻以及在该桶数组创建之后创建的第一个桶数组的创建时刻确定出的;The determining module is used to determine at least one bucket array that has been created, and determine the creation moment of each bucket array; each bucket array is used to store the user's browsing information in its corresponding storage period, any one The storage period corresponding to the bucket array is determined according to the creation time of the bucket array and the creation time of the first bucket array created after the bucket array is created;
获取模块,用于获取目标用户已浏览的至少一个用户浏览信息,并确定每个所述用户浏览信息的浏览时刻;an acquisition module, configured to acquire at least one user browsing information that the target user has browsed, and determine the browsing time of each of the user browsing information;
存储模块,用于根据每个所述用户浏览信息的浏览时刻以及每个所述桶数组对应的存储时段,将每个所述用户浏览信息对应存储在确定出的所述桶数组。The storage module is configured to store each of the user browsing information in the determined bucket array correspondingly according to the browsing time of each user browsing information and the storage period corresponding to each bucket array.
作为一种可选的实施方式,在本发明第二方面中,所述存储模块中根据每个所述用户浏览信息的浏览时刻以及每个所述桶数组对应的存储时段,将每个所述用户浏览信息对应存储在确定出的所述桶数组的具体方式为:As an optional implementation manner, in the second aspect of the present invention, in the storage module, according to the browsing time of each of the user browsing information and the storage period corresponding to each of the bucket arrays, each of the The specific manner in which the user browsing information is stored in the determined bucket array is as follows:
对于每个所述用户浏览信息,根据每个所述桶数组对应的存储时段,从所有所述桶数组对应的存储时段中确定该用户浏览信息的浏览时刻所处的目标存储时段,并将所述目标存储时段对应的目标桶数组确定为与该用户浏览信息对应的目标桶数组;对于每个所述用户浏览信息,将该用户浏览信息存储至与该用户浏览信息对应的目标桶数组。For each user browsing information, according to the storage period corresponding to each bucket array, determine the target storage period at which the browsing moment of the user browsing information is located from the storage periods corresponding to all the bucket arrays, and assign the The target bucket array corresponding to the target storage period is determined as the target bucket array corresponding to the user browsing information; for each user browsing information, the user browsing information is stored in the target bucket array corresponding to the user browsing information.
作为一种可选的实施方式,在本发明第二方面中,所述确定模块还用于确定待遍历的目标浏览信息唯一对应的标识信息;As an optional implementation manner, in the second aspect of the present invention, the determining module is further configured to determine the identification information uniquely corresponding to the target browsing information to be traversed;
所述装置还包括:The device also includes:
遍历模块,用于从当前存在的所有所述桶数组中,按照创建时长由长到短的顺序依次从当前存在的所有所述桶数组中遍历所述标识信息对应的所述目标浏览信息,直至遍历到所述目标浏览信息或者当前存在的所有所述桶数组被遍历完毕;其中,所述目标浏览信息为待查询用户浏览信息或者待删除用户浏览信息。The traversal module is used to traverse the target browsing information corresponding to the identification information from all the bucket arrays currently existing in the order of creation duration from long to short in sequence, until The traversal of the target browsing information or all the bucket arrays currently existing is completed; wherein, the target browsing information is the browsing information of the user to be queried or the browsing information of the user to be deleted.
作为一种可选的实施方式,在本发明第二方面中,所述存储模块中对于每个所述用户浏览信息,将该用户浏览信息存储在与该用户浏览信息对应的目标桶数组的具体方式为:As an optional implementation manner, in the second aspect of the present invention, for each user browsing information in the storage module, the user browsing information is stored in a specific location of the target bucket array corresponding to the user browsing information. The way is:
对于每个所述用户浏览信息,确定该用户浏览信息对应的标识信息,并通过预置的散列函数对该用户浏览信息对应的标识信息进行散列,得到该用户浏览信息对应的散列值,以及确定该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置;对于每个所述用户浏览信息,将该用户浏览信息对应的散列值存储在与该用户浏览信息对应的目标桶数组中的存储位置。For each user browsing information, the identification information corresponding to the user browsing information is determined, and the identification information corresponding to the user browsing information is hashed by a preset hash function to obtain a hash value corresponding to the user browsing information , and determine the storage location of the hash value corresponding to the user browsing information in the target bucket array corresponding to the user browsing information; for each user browsing information, the hash value corresponding to the user browsing information is stored in the target bucket array corresponding to the user browsing information; The storage location in the target bucket array corresponding to the user browsing information.
作为一种可选的实施方式,在本发明第二方面中,所述桶数组包括至少两个候选桶,所述存储模块中对于每个所述用户浏览信息,确定该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置的具体方式为:As an optional implementation manner, in the second aspect of the present invention, the bucket array includes at least two candidate buckets, and for each user browsing information, the storage module determines a bucket corresponding to the user browsing information. The specific way of storing the column value in the target bucket array corresponding to the user's browsing information is as follows:
对于每个所述用户浏览信息,通过预置的散列函数确定该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置,以及确定该用户浏览信息对应的散列值在对应的目标桶数组中的第二候选桶的存储位置;对于每个所述用户浏览信息,根据该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置的占用情况以及该用户浏览信息对应的散列值在对应的目标桶数组中的第二候选桶的存储位置的占用情况,确定该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置。For each user browsing information, the storage location of the first candidate bucket in the corresponding target bucket array of the hash value corresponding to the user browsing information is determined by a preset hash function, and the corresponding hash value of the user browsing information is determined. The storage location of the hash value in the second candidate bucket in the corresponding target bucket array; for each user browsing information, the first candidate bucket in the corresponding target bucket array according to the hash value corresponding to the user browsing information The occupancy of the storage location of the user's browsing information and the occupancy of the storage location of the second candidate bucket in the corresponding target bucket array of the hash value corresponding to the user's browsing information, determine that the hash value corresponding to the user's browsing information is the same as the user's browsing information. The storage location in the target bucket array corresponding to the information.
作为一种可选的实施方式,在本发明第二方面中,所述存储模块中对于每个所述用户浏览信息,根据该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置的占用情况以及该用户浏览信息对应的散列值在对应的目标桶数组中的第二候选桶的存储位置的占用情况,确定该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置的具体方式为:As an optional implementation manner, in the second aspect of the present invention, for each user browsing information in the storage module, according to the first hash value corresponding to the user browsing information in the corresponding target bucket array The occupancy of the storage location of a candidate bucket and the occupancy of the storage location of the second candidate bucket in the corresponding target bucket array of the hash value corresponding to the user's browsing information, determine that the hash value corresponding to the user's browsing information is in the same range as the user's browsing information. The specific method of the storage location in the target bucket array corresponding to the user browsing information is as follows:
对于每个所述用户浏览信息,检测该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置是否被占用,并在检测到该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置没有被占用时,将该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置确定为该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置;对于每个所述用户浏览信息,在检测到该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置被占用时,将该用户浏览信息对应的散列值在对应的目标桶数组中的第二候选桶的存储位置确定为该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置。For each user browsing information, it is detected whether the storage location of the first candidate bucket in the corresponding target bucket array of the hash value corresponding to the user browsing information is occupied, and when the hash value corresponding to the user browsing information is detected When the storage location of the first candidate bucket in the corresponding target bucket array is not occupied, the storage location of the first candidate bucket in the corresponding target bucket array of the hash value corresponding to the user's browsing information is determined as the user The storage location of the hash value corresponding to the browsing information in the target bucket array corresponding to the user browsing information; for each user browsing information, when it is detected that the hash value corresponding to the user browsing information is in the corresponding target bucket array When the storage location of the first candidate bucket is occupied, the storage location of the second candidate bucket in the corresponding target bucket array of the hash value corresponding to the user browsing information is determined as the hash value corresponding to the user browsing information in The storage location in the target bucket array corresponding to the user's browsing information.
作为一种可选的实施方式,在本发明第二方面中,所述确定模块还用于根据当前时刻和每个所述桶数组的创建时刻,确定每个所述桶数组的创建时长;As an optional implementation manner, in the second aspect of the present invention, the determining module is further configured to determine the creation duration of each of the bucket arrays according to the current moment and the creation moment of each of the bucket arrays;
所述装置还包括:The device also includes:
比较模块,用于对所有所述桶数组的创建时长中的最短创建时长和预置的第二预设时长进行比较,并在所述最短创建时长大于所述第二预设时长时,创建新的桶数组并将待插入浏览信息存储至所述新的桶数组;对于每个所述桶数组,对该桶数组的创建时长和预置的第三预设时长进行比较,并在该桶数组的创建时长大于所述第三预设时长时,从所有所述桶数组中删除该桶数组。The comparison module is used to compare the shortest creation duration among the creation durations of all the bucket arrays with the preset second preset duration, and when the shortest creation duration is greater than the second preset duration, create a new one. bucket array and store the browsing information to be inserted into the new bucket array; for each bucket array, compare the creation duration of the bucket array with the preset third preset duration, and record in the bucket array When the creation duration is greater than the third preset duration, the bucket array is deleted from all the bucket arrays.
本发明第三方面公开了另一种信息存储的装置,所述装置包括:A third aspect of the present invention discloses another information storage device, the device comprising:
存储有可执行程序代码的存储器;a memory in which executable program code is stored;
与所述存储器耦合的处理器;a processor coupled to the memory;
所述处理器调用所述存储器中存储的所述可执行程序代码,执行本发明第一方面公开的信息存储方法中的部分或全部步骤。The processor invokes the executable program code stored in the memory to execute part or all of the steps in the information storage method disclosed in the first aspect of the present invention.
本发明第四方面公开了一种计算机存储介质,所述计算机存储介质存储有计算机指令,所述计算机指令被调用时,用于执行本发明第一方面公开的信息存储方法中的部分或全部步骤。A fourth aspect of the present invention discloses a computer storage medium, the computer storage medium stores computer instructions, and when the computer instructions are invoked, is used to execute some or all of the steps in the information storage method disclosed in the first aspect of the present invention .
与现有技术相比,本发明实施例具有以下有益效果:Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
本发明实施例中,确定已创建的至少一个桶数组,并确定每个所述桶数组的创建时刻;每个所述桶数组用于存储与其对应的存储时段内的用户已浏览信息,任一所述桶数组对应的存储时段是根据该桶数组的创建时刻以及在该桶数组创建之后创建的第一个桶数组的创建时刻确定出的;获取目标用户已浏览的至少一个用户浏览信息,并确定每个所述用户浏览信息的浏览时刻;根据每个所述用户浏览信息的浏览时刻以及每个所述桶数组对应的存储时段,将每个所述用户浏览信息对应存储在确定出的所述桶数组。可见,实施本发明能够仅对用户浏览信息进行对应存储,节省了大量的存储空间,减少了存储成本。In this embodiment of the present invention, at least one bucket array that has been created is determined, and the creation time of each bucket array is determined; each bucket array is used to store the user's browsing information in its corresponding storage period, any one The storage period corresponding to the bucket array is determined according to the creation time of the bucket array and the creation time of the first bucket array created after the bucket array is created; obtain at least one user browsing information that the target user has browsed, and Determine the browsing time of each of the user browsing information; according to the browsing time of each of the user browsing information and the storage period corresponding to each of the bucket arrays, store each of the user browsing information in the determined array of buckets. It can be seen that by implementing the present invention, only user browsing information can be stored correspondingly, which saves a lot of storage space and reduces storage costs.
附图说明Description of drawings
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to illustrate the technical solutions in the embodiments of the present invention more clearly, the following briefly introduces the accompanying drawings used in the description of the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained from these drawings without creative effort.
图1是本发明实施例公开的一种信息存储的方法的流程示意图;1 is a schematic flowchart of a method for information storage disclosed in an embodiment of the present invention;
图2是本发明实施例公开的另一种信息存储方法的流程示意图;2 is a schematic flowchart of another information storage method disclosed in an embodiment of the present invention;
图3a是本发明实施例公开的一种创建桶数组的流程示意图;3a is a schematic flowchart of a bucket array creation disclosed in an embodiment of the present invention;
图3b是本发明实施例公开的一种删除桶数组的流程示意图;3b is a schematic flowchart of deleting a bucket array disclosed in an embodiment of the present invention;
图4是本发明实施例公开的一种信息存储的装置的结构示意图;4 is a schematic structural diagram of an apparatus for information storage disclosed in an embodiment of the present invention;
图5是本发明实施例公开的另一种信息存储的装置的结构示意图;5 is a schematic structural diagram of another information storage device disclosed in an embodiment of the present invention;
图6是本发明实施例公开的又一种信息存储的装置的结构示意图。FIG. 6 is a schematic structural diagram of another apparatus for information storage disclosed in an embodiment of the present invention.
具体实施方式Detailed ways
为了使本技术领域的人员更好地理解本发明方案,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make those skilled in the art better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only These are some embodiments of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
本发明的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别不同对象,而不是用于描述特定顺序。此外,术语“包括”和“具有”以及它们任何变形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、装置、产品或端没有限定于已列出的步骤或单元,而是可选地还包括没有列出的步骤或单元,或可选地还包括对于这些过程、方法、产品或端固有的其他步骤或单元。The terms "first", "second" and the like in the description and claims of the present invention and the above drawings are used to distinguish different objects, rather than to describe a specific order. Furthermore, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, device, product or process comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes unlisted steps or units, or optionally also includes Other steps or units inherent to these processes, methods, products or ends.
在本文中提及“实施例”意味着,结合实施例描述的特定特征、结构或特性可以包含在本发明的至少一个实施例中。在说明书中的各个位置出现该短语并不一定均是指相同的实施例,也不是与其它实施例互斥的独立的或备选的实施例。本领域技术人员显式地和隐式地理解的是,本文所描述的实施例可以与其它实施例相结合。Reference herein to an "embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the present invention. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor a separate or alternative embodiment that is mutually exclusive of other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
本发明公开了一种信息存储的方法及装置,能够仅对用户浏览信息进行对应存储,节省了大量的存储空间,减少了存储成本。以下分别进行详细说明。The invention discloses a method and device for storing information, which can only store user browsing information correspondingly, saves a lot of storage space and reduces storage cost. Each of them will be described in detail below.
实施例一Example 1
请参阅图1,图1是本发明实施例公开的一种信息存储的方法的流程示意图。其中,图1所描述的信息存储方法可以应用于终端设备中,也可以应用于互联网服务端中,本发明实施例不做限定。如图1所示,该信息存储方法可以包括以下操作:Please refer to FIG. 1. FIG. 1 is a schematic flowchart of an information storage method disclosed in an embodiment of the present invention. The information storage method described in FIG. 1 may be applied to a terminal device or an Internet server, which is not limited in this embodiment of the present invention. As shown in Figure 1, the information storage method may include the following operations:
步骤101,确定已创建的至少一个桶数组,并确定每个桶数组的创建时刻。Step 101: Determine at least one bucket array that has been created, and determine the creation moment of each bucket array.
其中,每个桶数组可以用于存储与其对应的存储时段内的用户已浏览信息,用户已浏览信息可以为用户在过去一段时间内浏览过的信息,任一桶数组对应的存储时段可以是根据该桶数组的创建时刻以及在该桶数组创建之后创建的第一个桶数组的创建时刻确定出的,每个桶数组可以包括至少两个候选桶,每个候选桶可以用于存储与其对应的存储时段内的用户已浏览信息,每个候选桶可以为具有一定长度的数组结构。Among them, each bucket array can be used to store the user's browsing information in its corresponding storage period, the user's browsing information can be the information that the user has browsed in the past period of time, and the storage period corresponding to any bucket array can be based on Determined at the creation time of the bucket array and the creation time of the first bucket array created after the bucket array is created, each bucket array may include at least two candidate buckets, and each candidate bucket may be used to store its corresponding The user's browsing information in the storage period, and each candidate bucket can be an array structure with a certain length.
为了存储用户在过去一段时间内浏览过的信息,可以预先创建至少一个桶数组,进而可以在需要存储用户在过去一段时间内浏览过的信息时,确定已创建的至少一个桶数组以及确定每个桶数组的创建时刻。In order to store the information browsed by the user in the past period of time, at least one bucket array can be created in advance, and then when it is necessary to store the information browsed by the user in the past period of time, the created at least one bucket array and each bucket array can be determined. The creation moment of the bucket array.
在实际应用中,在得到每个桶数组的创建时刻后,可以确定任一桶数组的创建时刻,以及确定在该桶数组创建之后创建的第一个桶数组的创建时刻,进而可以根据该桶数组的创建时刻以及在该桶数组创建之后创建的第一个桶数组的创建时刻,确定该桶数组对应的存储时段。In practical applications, after obtaining the creation time of each bucket array, the creation time of any bucket array can be determined, as well as the creation time of the first bucket array created after the bucket array is created, and then the bucket array can be created according to the bucket array. The creation time of the array and the creation time of the first bucket array created after the bucket array is created determine the storage period corresponding to the bucket array.
例如,可以确定桶数组A的创建时刻为12:00,并确定在桶数组A创建之后的第一个桶数组为桶数组B,以及确定桶数组B的创建时刻为13:00,进而可以根据桶数组A的创建时刻以及桶数组B的创建时刻确定桶数组A对应的存储时段为12:00至13:00的时段。For example, it can be determined that the creation time of the bucket array A is 12:00, the first bucket array after the bucket array A is created is determined to be the bucket array B, and the creation time of the bucket array B can be determined to be 13:00. The creation time of bucket array A and the creation time of bucket array B determine that the storage period corresponding to bucket array A is the time period from 12:00 to 13:00.
步骤102,获取目标用户已浏览的至少一个用户浏览信息,并确定每个用户浏览信息的浏览时刻。Step 102: Acquire at least one user browsing information that the target user has browsed, and determine the browsing time of each user's browsing information.
其中,目标用户可以为所有用户中需要推荐相关信息的用户,用户浏览信息可以包括文字信息、图像信息、视频信息等,任意一个用户浏览信息的浏览时刻可以为目标用户浏览该用户浏览信息的时刻。Among them, the target user can be a user who needs to recommend relevant information among all users, and the user browsing information can include text information, image information, video information, etc., and the browsing moment of any user browsing information can be the moment when the target user browses the user's browsing information. .
在检测到目标用户在过去一段时间内有浏览信息时,可以获取目标用户已浏览的至少一个用户浏览信息,并确定目标用户在浏览每个用户浏览信息时的浏览时刻。When it is detected that the target user has browsing information in the past period of time, at least one user browsing information that has been browsed by the target user can be obtained, and the browsing time when the target user browses each user's browsing information can be determined.
步骤103,根据每个用户浏览信息的浏览时刻以及每个桶数组对应的存储时段,将每个用户浏览信息对应存储在确定出的桶数组。
其中,每个桶数组可以分别对应不同的存储时段,存储时段可以为过去一段时间内的任意一段时段。Wherein, each bucket array may correspond to a different storage period, and the storage period may be any period of time in the past.
在得到每个用户浏览信息的浏览时刻以及每个桶数组对应的存储时段,可以根据每个用户浏览信息的浏览时刻以及每个桶数组对应的存储时段,将每个用户浏览信息对应存储在确定出的桶数组。After obtaining the browsing time of each user's browsing information and the storage period corresponding to each bucket array, each user's browsing information can be stored in a corresponding storage period according to the browsing time of each user's browsing information and the storage period corresponding to each bucket array. Array of buckets out.
在一个可选的实施例中,步骤103可以包括如下子步骤:In an optional embodiment, step 103 may include the following sub-steps:
子步骤11,对于每个用户浏览信息,根据每个桶数组对应的存储时段,从所有桶数组对应的存储时段中确定该用户浏览信息的浏览时刻所处的目标存储时段,并将目标存储时段对应的目标桶数组确定为与该用户浏览信息对应的目标桶数组。Sub-step 11: For each user browsing information, according to the storage period corresponding to each bucket array, determine the target storage period at which the browsing moment of the user browsing information is located from the storage periods corresponding to all bucket arrays, and assign the target storage period to the target storage period. The corresponding target bucket array is determined as the target bucket array corresponding to the user's browsing information.
其中,任一用户浏览信息对应的目标存储时段可以包含该用户浏览信息的浏览时刻,任一用户浏览信息对应的目标桶数组可以为所有桶数组中用于存储该用户浏览信息的桶数组。The target storage period corresponding to any user browsing information may include the browsing time of the user browsing information, and the target bucket array corresponding to any user browsing information may be a bucket array used to store the user browsing information among all bucket arrays.
在得到每个桶数组的创建时刻和每个桶数组对应的存储时段后,对于每个用户浏览信息,可以从所有桶数组对应的存储时段中确定该用户浏览信息的浏览时刻所处的目标存储时段,进而可以确定与该目标存储时段对应的桶数组为目标桶数组,并将该目标存储时段对应的目标桶数组确定为与该用户浏览信息对应的目标桶数组。After obtaining the creation time of each bucket array and the storage period corresponding to each bucket array, for each user browsing information, the target storage where the browsing time of the user browsing information is located can be determined from the storage periods corresponding to all bucket arrays period, and then the bucket array corresponding to the target storage period can be determined as the target bucket array, and the target bucket array corresponding to the target storage period can be determined as the target bucket array corresponding to the user browsing information.
例如,桶数组A对应的存储时段可以为12:00至13:00的时段,用户浏览信息a的浏览时刻可以为12:01,用户浏览信息b的浏览时刻可以为13:01,进而可以确定用户浏览信息a的浏览时刻处于桶数组A对应的存储时段中,则可以确定用户浏览信息a的浏览时刻所处的目标存储时段为12:00至13:00的时段,将桶数组A确定为与用户浏览信息a对应的目标桶数组,而用户浏览信息b的浏览时刻未处于桶数组A对应的存储时段中,则可以确定桶数组A并不是与用户浏览信息b对应的目标桶数组。For example, the storage period corresponding to bucket array A may be the period from 12:00 to 13:00, the browsing time of user browsing information a may be 12:01, and the browsing time of user browsing information b may be 13:01, and then it can be determined that If the browsing time of user browsing information a is in the storage period corresponding to bucket array A, it can be determined that the target storage period where the browsing time of user browsing information a is located is the period from 12:00 to 13:00, and bucket array A is determined as The target bucket array corresponding to the user browsing information a, and the browsing time of the user browsing information b is not in the storage period corresponding to the bucket array A, it can be determined that the bucket array A is not the target bucket array corresponding to the user browsing information b.
子步骤12,对于每个用户浏览信息,将该用户浏览信息存储至与该用户浏览信息对应的目标桶数组。Sub-step 12: For each user browsing information, store the user browsing information in a target bucket array corresponding to the user browsing information.
在确定每个用户浏览信息对应的目标桶数组后,对于每个用户浏览信息,可以将该用户浏览信息存储至与该用户浏览信息对应的目标桶数组中。After the target bucket array corresponding to each user browsing information is determined, for each user browsing information, the user browsing information may be stored in the target bucket array corresponding to the user browsing information.
在实际应用中,由于每个桶数组可以存储与其对应的存储时段内的用户浏览信息,进而可以仅将该用户浏览信息存储至与该用户浏览信息对应的目标桶数组中,而不需同时存储用户浏览信息和浏览时刻,节省了大量的存储空间,减少了存储成本。In practical applications, since each bucket array can store the user browsing information in its corresponding storage period, the user browsing information can be stored only in the target bucket array corresponding to the user browsing information, without simultaneously storing the user browsing information. Users browse information and browse moments, save a lot of storage space and reduce storage costs.
在一个可选的实施例中,该方法还可以包括如下步骤:In an optional embodiment, the method may further include the following steps:
确定待遍历的目标浏览信息唯一对应的标识信息;从当前存在的所有桶数组中,按照创建时长由长到短的顺序依次从当前存在的所有桶数组中遍历标识信息对应的目标浏览信息,直至遍历到目标浏览信息或者当前存在的所有桶数组被遍历完毕。Determine the identification information uniquely corresponding to the target browsing information to be traversed; from all the bucket arrays that currently exist, traverse the target browsing information corresponding to the identification information from all the bucket arrays currently existing in the order of creation time from long to short, until Traversing to the target browsing information or all the bucket arrays that currently exist has been traversed.
其中,目标浏览信息可以为待查询用户浏览信息或者待删除用户浏览信息,待遍历的目标浏览信息可以为人为选定的用户浏览信息,目标浏览信息唯一对应的标识信息可以为用于表示目标浏览信息的身份,标识信息可以包括目标浏览信息的标签信息、标题信息、摘要信息、序号信息等,创建时长可以为桶数组的创建时长,任一桶数组的创建时长可以通过该桶数组的创建时刻和当前时刻确定的。The target browsing information may be the browsing information of the user to be queried or the browsing information of the user to be deleted, the target browsing information to be traversed may be the browsing information of the user selected manually, and the identification information uniquely corresponding to the target browsing information may be used to indicate the target browsing information. The identity of the information, and the identification information can include the tag information, title information, summary information, serial number information, etc. of the target browsing information. The creation time can be the creation time of the bucket array. The creation time of any bucket array can be determined by the creation time of the bucket array. and the current moment.
在将每个用户浏览信息对应存储在确定出的桶数组后,可以从每个用户浏览信息中,确定人为选定的目标浏览信息,并确定目标浏览信息唯一对应的标识信息,进而可以从当前存在的所有桶数组中,按照创建时长由长到短的顺序依次从当前存在的所有桶数组存储的用户浏览信息中,遍历与标识信息对应的目标浏览信息,直至遍历到目标浏览信息或者当前存在的所有桶数组被遍历完毕,以在遍历到目标浏览信息时输出目标浏览信息或删除目标浏览信息,在当前存在的所有桶数组被遍历完毕也没有遍历到目标浏览信息时则认为所有桶数组中不存在目标浏览信息。After each user's browsing information is correspondingly stored in the determined bucket array, the artificially selected target browsing information can be determined from each user's browsing information, and the uniquely corresponding identification information of the target browsing information can be determined. In all bucket arrays that exist, traverse the target browsing information corresponding to the identification information from the user browsing information stored in all existing bucket arrays in the order of creation time from long to short, until the target browsing information or the currently existing bucket array is traversed. All bucket arrays of the bucket have been traversed to output the target browsing information or delete the target browsing information when the target browsing information is traversed. When all the currently existing bucket arrays have been traversed and the target browsing information has not been traversed, it is considered that all bucket arrays are in the target browsing information. No target browsing information exists.
在一个可选的实施例中,目标浏览信息还可以为向目标用户推荐的相关信息,在向目标用户推荐相关信息时,可以确定当前存在的所有桶数组中是否确定与向目标用户推荐的相关信息对应的用户浏览信息,以删除用户最近一段时间浏览过的信息,因此可以通过对当前存在的所有桶数组进行目标浏览信息的遍历,以确定当前存在的所有桶数组中是否存在目标浏览信息。In an optional embodiment, the target browsing information may also be related information recommended to the target user. When recommending the related information to the target user, it may be determined whether all the bucket arrays currently existing are determined to be related to the recommended user. The user browsing information corresponding to the information can delete the information that the user has browsed in the recent period. Therefore, it can be determined whether there is target browsing information in all the currently existing bucket arrays by traversing the target browsing information of all the bucket arrays currently existing.
在一个可选的实施例中,对于每个用户浏览信息,在将该用户浏览信息存储至与该用户浏览信息对应的目标桶数组时,可以确定该用户浏览信息唯一对应的标识信息,进而可以将该用户浏览信息唯一对应的标识信息存储至与该用户浏览信息对应的目标桶数组中,进一步节省存储空间,并且在对当前存在的所有桶数组进行目标浏览信息的遍历时,可以通过查询匹配的标识信息的方法来确定当前存在的所有桶数组中是否存在目标浏览信息,提高了遍历效率。In an optional embodiment, for each user browsing information, when the user browsing information is stored in the target bucket array corresponding to the user browsing information, the identification information uniquely corresponding to the user browsing information may be determined, and then the user browsing information may be uniquely corresponding to the identification information. The identification information uniquely corresponding to the user's browsing information is stored in the target bucket array corresponding to the user's browsing information, which further saves storage space, and when traversing the target browsing information for all currently existing bucket arrays, it can be matched by query. The method of identifying information is used to determine whether there is target browsing information in all the bucket arrays currently existing, which improves the traversal efficiency.
本发明实施例中,确定已创建的至少一个桶数组,并确定每个所述桶数组的创建时刻;每个所述桶数组用于存储与其对应的存储时段内的用户已浏览信息,任一所述桶数组对应的存储时段是根据该桶数组的创建时刻以及在该桶数组创建之后创建的第一个桶数组的创建时刻确定出的;获取目标用户已浏览的至少一个用户浏览信息,并确定每个所述用户浏览信息的浏览时刻;根据每个所述用户浏览信息的浏览时刻以及每个所述桶数组对应的存储时段,将每个所述用户浏览信息对应存储在确定出的所述桶数组。可见,实施本发明能够仅对用户浏览信息进行对应存储,节省了大量的存储空间,减少了存储成本。In this embodiment of the present invention, at least one bucket array that has been created is determined, and the creation time of each bucket array is determined; each bucket array is used to store the user's browsing information in its corresponding storage period, any one The storage period corresponding to the bucket array is determined according to the creation time of the bucket array and the creation time of the first bucket array created after the bucket array is created; obtain at least one user browsing information that the target user has browsed, and Determine the browsing time of each of the user browsing information; according to the browsing time of each of the user browsing information and the storage period corresponding to each of the bucket arrays, store each of the user browsing information in the determined array of buckets. It can be seen that by implementing the present invention, only user browsing information can be stored correspondingly, which saves a lot of storage space and reduces storage costs.
请参阅图2,图2是本发明实施例公开的另一种信息存储的方法的流程示意图。其中,图2所描述的信息存储方法可以应用于终端设备中,也可以应用于互联网服务端中,本发明实施例不做限定。如图2所示,该信息存储方法可以包括以下操作:Please refer to FIG. 2 , which is a schematic flowchart of another information storage method disclosed in an embodiment of the present invention. The information storage method described in FIG. 2 may be applied to a terminal device or an Internet server, which is not limited in this embodiment of the present invention. As shown in Figure 2, the information storage method may include the following operations:
步骤201,确定已创建的至少一个桶数组,并确定每个桶数组的创建时刻。Step 201: Determine at least one bucket array that has been created, and determine the creation moment of each bucket array.
步骤202,获取目标用户已浏览的至少一个用户浏览信息,并确定每个用户浏览信息的浏览时刻。Step 202: Acquire at least one user browsing information that the target user has browsed, and determine the browsing time of each user browsing information.
步骤203,对于每个用户浏览信息,根据每个桶数组对应的存储时段,从所有桶数组对应的存储时段中确定该用户浏览信息的浏览时刻所处的目标存储时段,并将目标存储时段对应的目标桶数组确定为与该用户浏览信息对应的目标桶数组。
步骤204,对于每个用户浏览信息,确定该用户浏览信息对应的标识信息,并通过预置的散列函数对该用户浏览信息对应的标识信息进行散列,得到该用户浏览信息对应的散列值,以及确定该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置。Step 204: For each user browsing information, determine the identification information corresponding to the user browsing information, and hash the identification information corresponding to the user browsing information through a preset hash function to obtain a hash corresponding to the user browsing information value, and determine the storage location of the hash value corresponding to the user browsing information in the target bucket array corresponding to the user browsing information.
其中,散列函数可以用于将任意长度的标识信息通过散列算法变换成固定长度的散列值,并得到散列值与相应的存储位置的映射关系,散列值可以为通过散列算法得到的与标识信息唯一对应的数值。Among them, the hash function can be used to transform the identification information of any length into a hash value of a fixed length through a hash algorithm, and obtain the mapping relationship between the hash value and the corresponding storage location, and the hash value can be obtained by the hash algorithm. The obtained value uniquely corresponds to the identification information.
在确定每个用户浏览信息对应的目标桶数组后,对于每个用户浏览信息,可以确定该用户浏览信息对应的标识信息,进而可以通过预置的散列函数对该用户浏览信息对应的标识信息进行散列,得到该用户浏览信息对应的散列值,可以通过散列值与目标桶数组的存储位置的映射关系,确定该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置。After the target bucket array corresponding to each user's browsing information is determined, for each user's browsing information, the identification information corresponding to the user's browsing information can be determined, and then the identification information corresponding to the user's browsing information can be determined through a preset hash function Perform hashing to obtain the hash value corresponding to the user's browsing information. Through the mapping relationship between the hash value and the storage location of the target bucket array, it can be determined that the hash value corresponding to the user's browsing information is in the target corresponding to the user's browsing information. The storage location in the bucket array.
在实际应用中,在创建桶数组时,可以预先构建散列函数,并根据该散列函数创建与该散列函数对应的至少一个候选桶,进而可以根据每个候选桶,生成桶数组,且该散列函数输出的散列值可以与该桶数组中每个候选桶的存储位置具有映射关系。In practical applications, when creating a bucket array, a hash function can be constructed in advance, and at least one candidate bucket corresponding to the hash function can be created according to the hash function, and then a bucket array can be generated according to each candidate bucket, and The hash value output by the hash function may have a mapping relationship with the storage location of each candidate bucket in the bucket array.
例如,桶数组A可以包括候选桶1,候选桶1可以为具有8字节长度的数组结构,可以确定用户浏览信息a对应的标识信息,并通过散列函数对用户浏览信息a对应的标识信息进行散列,得到散列值57,以及根据散列值与候选桶1的存储位置的映射关系,确定散列值57在候选桶1的存储位置为候选桶1的第5个字节。For example, bucket array A may include candidate bucket 1, and candidate bucket 1 may be an array structure with a length of 8 bytes. Identification information corresponding to user browsing information a may be determined, and the identification information corresponding to user browsing information a may be determined through a hash function. Perform hashing to obtain a hash value 57, and according to the mapping relationship between the hash value and the storage location of candidate bucket 1, determine that the storage location of hash value 57 in candidate bucket 1 is the fifth byte of candidate bucket 1.
步骤205,对于每个用户浏览信息,将该用户浏览信息对应的散列值存储在与该用户浏览信息对应的目标桶数组中的存储位置。Step 205: For each user browsing information, store the hash value corresponding to the user browsing information in a storage location in the target bucket array corresponding to the user browsing information.
在得到每个用户浏览信息对应的散列值,以及确定每个用户浏览信息对应的散列值的存储位置后,对于每个用户浏览信息,可以将该用户浏览信息对应的散列值存储在与该用户浏览信息对应的目标桶数组中的存储位置中。After obtaining the hash value corresponding to each user's browsing information and determining the storage location of the hash value corresponding to each user's browsing information, for each user's browsing information, the hash value corresponding to the user's browsing information can be stored in the In the storage location in the target bucket array corresponding to the user's browsing information.
在实际应用中,由于通过散列函数对标识信息进行散列,可以得到长度较小的散列值,即该散列值所占用的空间较小,而仅将散列值存储在与该用户浏览信息对应的目标桶数组中的存储位置,则可以进一步节省了存储空间。In practical applications, since the identification information is hashed by a hash function, a hash value with a smaller length can be obtained, that is, the space occupied by the hash value is smaller, and the hash value is only stored in the same location as the user. By browsing the storage location in the target bucket array corresponding to the information, the storage space can be further saved.
在具体实施中,由于通过散列函数可以得到散列值与该散列值在桶数组中的存储位置的映射关系,进而可以在对当前存在的所有桶数组进行目标浏览信息的遍历时,通过该映射关系以及目标浏览信息对应的散列值,确定当前存在的所有桶数组中是否存在目标浏览信息,而无需对所有桶数组进行全部遍历,即仅需遍历一次即可确定当前存在的所有桶数组中是否存在目标浏览信息,进一步提高了遍历效率和查询效率。In the specific implementation, since the mapping relationship between the hash value and the storage position of the hash value in the bucket array can be obtained through the hash function, and then when the target browsing information is traversed for all the bucket arrays currently existing, the The mapping relationship and the hash value corresponding to the target browsing information determine whether the target browsing information exists in all the bucket arrays currently existing, without traversing all the bucket arrays, that is, only one traversal can determine all the buckets that currently exist. Whether there is target browsing information in the array further improves the traversal efficiency and query efficiency.
在一个可选的实施例中,步骤205可以包括如下子步骤:In an optional embodiment, step 205 may include the following sub-steps:
子步骤21,对于每个用户浏览信息,通过预置的散列函数确定该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置,以及确定该用户浏览信息对应的散列值在对应的目标桶数组中的第二候选桶的存储位置。Sub-step 21, for each user browsing information, determine the storage location of the first candidate bucket in the corresponding target bucket array of the hash value corresponding to the user browsing information through a preset hash function, and determine the user browsing information The storage location of the corresponding hash value in the second candidate bucket in the corresponding target bucket array.
在得到每个用户浏览信息对应的散列值,以及确定每个用户浏览信息对应的散列值的存储位置后,对于每个用户浏览信息,可以通过预置的散列函数确定该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置,以及确定该用户浏览信息对应的散列值在对应的目标桶数组中的第二候选桶的存储位置。After obtaining the hash value corresponding to each user's browsing information and determining the storage location of the hash value corresponding to each user's browsing information, for each user's browsing information, the user's browsing information can be determined through a preset hash function The storage location of the corresponding hash value in the first candidate bucket in the corresponding target bucket array, and the storage location of the second candidate bucket in the corresponding target bucket array of the hash value corresponding to the user browsing information is determined.
在实际应用中,由于候选桶可以为具有一定长度的数组结构,即长度是有限的,进而每个候选桶所能存储的散列值也是有限的,则可以通过建立多个候选桶来存储更多的散列值,并在存储散列值时通过散列函数确定散列值在每个候选桶的存储位置。In practical applications, since the candidate bucket can be an array structure with a certain length, that is, the length is limited, and the hash value that each candidate bucket can store is also limited, then multiple candidate buckets can be established to store more When storing the hash value, the storage location of the hash value in each candidate bucket is determined by the hash function.
子步骤22,对于每个用户浏览信息,根据该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置的占用情况以及该用户浏览信息对应的散列值在对应的目标桶数组中的第二候选桶的存储位置的占用情况,确定该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置。Sub-step 22, for each user browsing information, according to the occupancy of the storage location of the first candidate bucket in the corresponding target bucket array according to the hash value corresponding to the user browsing information and the hash value corresponding to the user browsing information in The occupancy of the storage location of the second candidate bucket in the corresponding target bucket array determines the storage location of the hash value corresponding to the user browsing information in the target bucket array corresponding to the user browsing information.
其中,占用情况可以包括:对于每个用户浏览信息,有其他用户浏览信息对应的散列值存储在该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置,以及,该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置没有存储其他用户浏览信息对应的散列值。Wherein, the occupancy may include: for each user browsing information, there is a storage location of the first candidate bucket where the hash value corresponding to the browsing information of other users is stored in the first candidate bucket in the corresponding target bucket array. , and the hash value corresponding to the user browsing information does not store the hash value corresponding to other user browsing information in the storage location of the first candidate bucket in the corresponding target bucket array.
在确定每个散列值在桶数组中的第一候选桶的存储位置,以及在桶数组中的第二候选桶的存储位置后,对于每个用户浏览信息,可以根据该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置的占用情况以及该用户浏览信息对应的散列值在对应的目标桶数组中的第二候选桶的存储位置的占用情况,确定该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置。After determining the storage location of each hash value in the first candidate bucket in the bucket array, and the storage location of the second candidate bucket in the bucket array, for each user browsing information, the corresponding user browsing information can be The occupancy of the storage location of the hash value in the first candidate bucket in the corresponding target bucket array and the occupancy of the storage location of the second candidate bucket in the corresponding target bucket array of the hash value corresponding to the user browsing information, Determine the storage location of the hash value corresponding to the user browsing information in the target bucket array corresponding to the user browsing information.
在实际应用中,由于每个候选桶中都具有与每个散列值分别对应的唯一存储位置,则对于每个用户浏览信息对应的散列值,可以通过确定每个候选桶中与该散列值对应的存储位置的占用情况,进而可以根据每个候选桶中与该散列值对应的存储位置的占用情况,从每个候选桶中选取存储该散列值的目标候选桶,以及确定目标候选桶中与该散列值对应的存储位置,即为该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置。In practical applications, since each candidate bucket has a unique storage location corresponding to each hash value, the hash value corresponding to each user browsing information can be determined by determining the corresponding hash value in each candidate bucket. The occupancy of the storage location corresponding to the column value, and then according to the occupancy of the storage location corresponding to the hash value in each candidate bucket, select the target candidate bucket for storing the hash value from each candidate bucket, and determine The storage location corresponding to the hash value in the target candidate bucket is the storage location of the hash value corresponding to the user browsing information in the target bucket array corresponding to the user browsing information.
在一个可选的实施例中,对于每个用户浏览信息,还可以检测该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置是否被占用,并在检测到该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置没有被占用时,将该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置确定为该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置。In an optional embodiment, for each user browsing information, it is also possible to detect whether the storage position of the first candidate bucket in the corresponding target bucket array of the hash value corresponding to the user browsing information is occupied, and check whether the storage position of the first candidate bucket in the corresponding target bucket array is occupied. When the storage location of the first candidate bucket in the corresponding target bucket array for the hash value corresponding to the user browsing information is not occupied, the hash value corresponding to the user browsing information is the first candidate bucket in the corresponding target bucket array. The storage location of the candidate bucket is determined as the storage location of the hash value corresponding to the user browsing information in the target bucket array corresponding to the user browsing information.
在实际应用中,对于每个用户浏览信息,在检测到该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置没有被占用时,则可以认为第一候选桶具有足够的存储空间来存储该用户浏览信息对应的散列值,进而可以将该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置确定为该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置。In practical applications, for each user browsing information, when it is detected that the hash value corresponding to the user browsing information is not occupied in the storage location of the first candidate bucket in the corresponding target bucket array, it can be considered that the first candidate bucket is not occupied. The bucket has enough storage space to store the hash value corresponding to the user browsing information, and then the storage location of the first candidate bucket in the corresponding target bucket array for the hash value corresponding to the user browsing information can be determined as the user browsing information. The storage location of the hash value corresponding to the information in the target bucket array corresponding to the user's browsing information.
对于每个用户浏览信息,在检测到该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置被占用时,将该用户浏览信息对应的散列值在对应的目标桶数组中的第二候选桶的存储位置确定为该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置。For each user browsing information, when it is detected that the hash value corresponding to the user browsing information is occupied in the storage location of the first candidate bucket in the corresponding target bucket array, the hash value corresponding to the user browsing information is stored in the corresponding The storage location of the second candidate bucket in the target bucket array is determined as the storage location of the hash value corresponding to the user browsing information in the target bucket array corresponding to the user browsing information.
在实际应用中,在检测到该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置被占用时,则可以认为第一候选桶存储空间不足以存储该用户浏览信息对应的散列值,进而可以将该用户浏览信息对应的散列值在对应的目标桶数组中的第二候选桶的存储位置确定为该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置。In practical applications, when it is detected that the hash value corresponding to the user's browsing information is occupied in the storage location of the first candidate bucket in the corresponding target bucket array, it can be considered that the storage space of the first candidate bucket is insufficient to store the user The hash value corresponding to the browsing information, and then the storage location of the second candidate bucket in the corresponding target bucket array of the hash value corresponding to the user browsing information can be determined as the hash value corresponding to the user browsing information Browse the storage location in the target bucket array corresponding to the browsing information.
在一个可选的实施例中,对于每个用户浏览信息,在检测到该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置被占用时,还可以确定该用户浏览信息对应的散列值在对应的目标桶数组中的第二候选桶的存储位置是否被占用,并在检测到该用户浏览信息对应的散列值在对应的目标桶数组中的第二候选桶的存储位置被占用时,将存储在该用户浏览信息对应的散列值在对应的目标桶数组中的第二候选桶的存储位置中的散列值移除,以将该用户浏览信息对应的散列值存储在该用户浏览信息对应的散列值在对应的目标桶数组中的第二候选桶的存储位置中。In an optional embodiment, for each user browsing information, when it is detected that the hash value corresponding to the user browsing information is occupied in the storage position of the first candidate bucket in the corresponding target bucket array, it can also be determined that Whether the storage location of the second candidate bucket in the corresponding target bucket array for the hash value corresponding to the user browsing information is occupied, and when it is detected that the hash value corresponding to the user browsing information is in the second candidate bucket in the corresponding target bucket array When the storage location of the second candidate bucket is occupied, the hash value stored in the storage location of the second candidate bucket in the corresponding target bucket array of the hash value corresponding to the user's browsing information is removed, so that the user can browse the information. The hash value corresponding to the information is stored in the storage location of the second candidate bucket in the corresponding target bucket array where the hash value corresponding to the user browsing information is stored.
在实际应用中,对于每个用户浏览信息,在将存储在该用户浏览信息对应的散列值在对应的目标桶数组中的第二候选桶的存储位置中的散列值移除后,由于任一散列值在所有候选桶中具有对应的存储位置,进而在移除该散列值后,可以从所有候选桶中选取具有足够的存储空间存储该散列值的候选桶,以存储该移除后的散列值。In practical applications, for each user browsing information, after removing the hash value stored in the storage location of the second candidate bucket in the corresponding target bucket array, the hash value corresponding to the user browsing information is removed. Any hash value has a corresponding storage location in all candidate buckets, and after removing the hash value, a candidate bucket with sufficient storage space to store the hash value can be selected from all candidate buckets to store the hash value. The hash value after removal.
在一个可选的实施例中,对于每个用户浏览信息,在检测到该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置被占用时,还可以存储在该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置中的散列值移除,以将该用户浏览信息对应的散列值存储在该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置中。In an optional embodiment, for each user browsing information, when it is detected that the hash value corresponding to the user browsing information is occupied in the storage position of the first candidate bucket in the corresponding target bucket array, the storage The hash value corresponding to the user browsing information is removed from the storage location of the first candidate bucket in the corresponding target bucket array, so as to store the hash value corresponding to the user browsing information in the user browsing information The corresponding hash value is in the storage location of the first candidate bucket in the corresponding target bucket array.
在实际应用中,对于每个用户浏览信息,在将存储在该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置中的散列值移除后,由于任一散列值在所有候选桶中具有对应的存储位置,进而在移除该散列值后,可以从所有候选桶中选取具有足够的存储空间存储该散列值的候选桶,以存储该移除后的散列值。In practical applications, for each user browsing information, after removing the hash value stored in the storage location of the first candidate bucket in the corresponding target bucket array, the hash value corresponding to the user browsing information is removed. Any hash value has a corresponding storage location in all candidate buckets, and after removing the hash value, a candidate bucket with sufficient storage space to store the hash value can be selected from all candidate buckets to store the hash value. The hash value after removal.
在一个可选的实施例中,该方法还可以包括如下步骤:In an optional embodiment, the method may further include the following steps:
根据当前时刻和每个桶数组的创建时刻,确定每个桶数组的创建时长;对所有桶数组的创建时长中的最短创建时长和预置的第一预设时长进行比较,并在最短创建时长大于等于第一预设时长时,创建新的桶数组并将待插入浏览信息存储至新的桶数组;对于每个桶数组,对该桶数组的创建时长和预置的第二预设时长进行比较,并在该桶数组的创建时长大于第二预设时长时,从所有桶数组中删除该桶数组。Determine the creation duration of each bucket array according to the current moment and the creation moment of each bucket array; When the duration is greater than or equal to the first preset duration, a new bucket array is created and the browsing information to be inserted is stored in the new bucket array; for each bucket array, the creation duration of the bucket array and the preset second preset duration are performed. Compare, and delete the bucket array from all bucket arrays when the creation duration of the bucket array is greater than the second preset duration.
其中,最短创建时长可以为所有桶数组的创建时长中值最小的创建时长,第一预设时长与第二预设时长可以为人为设定的,待插入浏览信息可以为所有用户浏览信息中创建时刻不处于当前存在的所有桶数组对应的存储时段中的用户浏览信息。The shortest creation duration can be the creation duration with the smallest median of the creation durations of all bucket arrays, the first preset duration and the second preset duration can be set manually, and the browsing information to be inserted can be created in the browsing information of all users User browsing information that is not in the storage period corresponding to all currently existing bucket arrays at the moment.
在获取每个桶数组的创建时刻后,可以确定当前时刻与每个桶数组的创建时刻之间的差值,进而可以将当前时刻与每个桶数组的创建时刻之间的差值确定为每个桶数组的创建时长,并确定差值最小的创建时长为最短创建时长,可以将最短创建时长和预置的第一预设时长进行比较,进而可以在最短创建时长大于第一预设时长时,创建新的桶数组并将待插入浏览信息存储至新的桶数组。After obtaining the creation time of each bucket array, the difference between the current time and the creation time of each bucket array can be determined, and then the difference between the current time and the creation time of each bucket array can be determined as each bucket array. The creation duration of the bucket array is determined, and the creation duration with the smallest difference is determined as the shortest creation duration. The shortest creation duration can be compared with the preset first preset duration, and then the shortest creation duration can be greater than the first preset duration. , create a new bucket array and store the browsing information to be inserted into the new bucket array.
在实际应用中,在确定最短创建时长大于等于第一预设时长时,则可以说明当前存在的所有桶数组对应的存储时段中不包含当前时刻,进而不能对应存储当前时刻获取的用户浏览信息,即不能存储待插入浏览信息,可以在确定最短创建时长大于第一预设时长时,通过创建新的桶数组,以将待插入浏览信息存储至新的桶数组中。In practical applications, when it is determined that the shortest creation duration is greater than or equal to the first preset duration, it can be indicated that the storage period corresponding to all the bucket arrays currently existing does not include the current moment, and thus the user browsing information obtained at the current moment cannot be stored correspondingly. That is, the browsing information to be inserted cannot be stored, and when it is determined that the shortest creation duration is greater than the first preset duration, a new bucket array is created to store the browsing information to be inserted in the new bucket array.
请参阅图3a,图3a是本发明实施例公开的一种创建桶数组的流程示意图。如图3a所示,过滤器2可以为第一桶数组,且过滤器2的创建时刻可以为2,过滤器3可以为第二桶数组,且过滤器3的创建时刻可以为3,而当前时刻可以为4,第一预设时长可以为1,进而可以确定最短创建时长为过滤器3的创建时长,即最短创建时长为1,则可以确定最短创建时长大于等于第一预设时长,创建新的过滤器4,即创建新的桶数组,且过滤器4的创建时刻为4。Please refer to FIG. 3a. FIG. 3a is a schematic flowchart of a bucket array creation disclosed in an embodiment of the present invention. As shown in Figure 3a, filter 2 can be the first bucket array, and the creation time of filter 2 can be 2, filter 3 can be the second bucket array, and the creation time of filter 3 can be 3, and the current The moment can be 4, the first preset duration can be 1, and then it can be determined that the shortest creation duration is the creation duration of filter 3, that is, the shortest creation duration is 1, then it can be determined that the shortest creation duration is greater than or equal to the first preset duration, and the creation The new filter 4 is to create a new bucket array, and the creation time of filter 4 is 4.
在确定每个桶数组的创建时长后,对于每个桶数组,可以对该桶数组的创建时长和预置的第二预设时长进行比较,并在该桶数组的创建时长大于第二预设时长时,从所有桶数组中删除该桶数组。After the creation duration of each bucket array is determined, for each bucket array, the creation duration of the bucket array may be compared with a preset second preset duration, and if the creation duration of the bucket array is greater than the second preset duration When the duration is too long, delete the bucket array from all bucket arrays.
在实际应用中,可以根据信息推荐策略,确定用户最近N天浏览的信息为用户最近浏览的信息,进而可以在推荐相关信息时,不向目标用户推荐用户最近N天浏览的信息,可以确定用户最近N+1天浏览的信息为用户未浏览信息,进而可以在推荐相关信息时,向目标用户推荐用户最近N+1天浏览的信息,其中,N可以为与信息推荐策略对应的,也可以为人为设定的值,如确定用户最近3天浏览的信息为用户最近浏览的信息。In practical applications, according to the information recommendation strategy, it can be determined that the information browsed by the user in the last N days is the information browsed by the user recently, and then when recommending related information, the information browsed by the user in the last N days can be determined without recommending the target user. The information browsed in the last N+1 days is the information that the user has not browsed, and then when recommending related information, the target user can recommend the information browsed by the user in the last N+1 days, where N can be corresponding to the information recommendation strategy, or It is an artificially set value, for example, it is determined that the information browsed by the user in the last 3 days is the information browsed by the user recently.
则对于每个桶数组,在该桶数组的创建时长大于第二预设时长时,可以说明该桶数组中存储的所有用户浏览信息为用户未浏览信息,可以在推荐相关信息时,向目标用户推荐该桶数组中存储的所有用户浏览信息,并在推荐相关信息时,无需确定该桶数组中是否存在与向目标用户推荐的相关信息对应的用户浏览信息,进而可以从所有桶数组中删除该桶数组。Then for each bucket array, when the creation duration of the bucket array is greater than the second preset duration, it can be indicated that all user browsing information stored in the bucket array is the user's unbrowsed information, and the target user can be recommended when recommending relevant information. All user browsing information stored in the bucket array is recommended, and when recommending related information, there is no need to determine whether there is user browsing information corresponding to the relevant information recommended to the target user in the bucket array, and then the bucket array can be deleted from all bucket arrays. Array of buckets.
请参阅图3b,图3b是本发明实施例公开的一种删除桶数组的流程示意图。如图3b所示,过滤器1可以为第一桶数组,且过滤器1的创建时刻可以为1,过滤器2可以为第二桶数组,且过滤器2的创建时刻可以为2,过滤器3可以为第三桶数组,且过滤器3的创建时刻可以为3,而当前时刻可以为4,第一预设时长可以为2,进而可以确定过滤器1的创建时长为3,过滤器2的创建时长为2,过滤3的创建时长为1,则可以确定过滤器1的创建时长大于第一预设时长,过滤器2以及过滤器3的创建时长小于第一预设时长,进而可以删除过滤器1。Please refer to FIG. 3b. FIG. 3b is a schematic flowchart of deleting a bucket array according to an embodiment of the present invention. As shown in Figure 3b, filter 1 can be the first bucket array, and the creation time of filter 1 can be 1, filter 2 can be the second bucket array, and the creation time of filter 2 can be 2, and the filter 3 can be the third bucket array, and the creation time of filter 3 can be 3, the current time can be 4, the first preset duration can be 2, and then it can be determined that the creation duration of filter 1 is 3, and filter 2 The creation duration of filter 3 is 2, and the creation duration of filter 3 is 1, then it can be determined that the creation duration of filter 1 is greater than the first preset duration, and the creation duration of filter 2 and filter 3 is shorter than the first preset duration, and then can be deleted. filter 1.
由此可见,在本发明实施例中,仅对用户浏览信息对应的散列值进行对应存储,也可以按时间删除对应的用户浏览信息,具有按时间淘汰信息的功能。It can be seen that, in the embodiment of the present invention, only the hash value corresponding to the user browsing information is stored correspondingly, and the corresponding user browsing information can also be deleted according to time, which has the function of eliminating information according to time.
本发明实施例中,确定已创建的至少一个桶数组,并确定每个桶数组的创建时刻,获取目标用户已浏览的至少一个用户浏览信息,并确定每个用户浏览信息的浏览时刻,对于每个用户浏览信息,根据每个桶数组对应的存储时段,从所有桶数组对应的存储时段中确定该用户浏览信息的浏览时刻所处的目标存储时段,并将目标存储时段对应的目标桶数组确定为与该用户浏览信息对应的目标桶数组,对于每个用户浏览信息,确定该用户浏览信息对应的标识信息,并通过预置的散列函数对该用户浏览信息对应的标识信息进行散列,得到该用户浏览信息对应的散列值,以及确定该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置步骤,对于每个用户浏览信息,将该用户浏览信息对应的散列值存储在与该用户浏览信息对应的目标桶数组中的存储位置。可见,实施本发明能够仅对用户浏览信息对应的散列值进行对应存储,进一步节省了大量的存储空间,减少了存储成本。In this embodiment of the present invention, at least one bucket array that has been created is determined, and the creation time of each bucket array is determined, at least one user browsing information that has been browsed by the target user is obtained, and the browsing time of each user's browsing information is determined. According to the storage period corresponding to each bucket array, the target storage period at which the browsing moment of the user browsing information is located is determined from the storage periods corresponding to all bucket arrays, and the target bucket array corresponding to the target storage period is determined. is the target bucket array corresponding to the user browsing information, for each user browsing information, determine the identification information corresponding to the user browsing information, and hash the identification information corresponding to the user browsing information through a preset hash function, The steps of obtaining the hash value corresponding to the user browsing information, and determining the storage location of the hash value corresponding to the user browsing information in the target bucket array corresponding to the user browsing information, for each user browsing information, the user browsing information The hash value corresponding to the information is stored in the storage location in the target bucket array corresponding to the user's browsing information. It can be seen that by implementing the present invention, only the hash value corresponding to the user's browsing information can be stored correspondingly, which further saves a large amount of storage space and reduces the storage cost.
实施例三Embodiment 3
请参阅图4,图4是本发明实施例公开的一种信息存储的装置的结构示意图。如图4所示,该信息存储的装置可以应用于终端设备中,也可以应用于互联网服务端中,该信息存储的装置可以包括:Please refer to FIG. 4 , which is a schematic structural diagram of an apparatus for information storage disclosed in an embodiment of the present invention. As shown in FIG. 4 , the apparatus for storing information can be applied to a terminal device or an Internet server, and the apparatus for storing information can include:
确定模块401,用于确定已创建的至少一个桶数组,并确定每个桶数组的创建时刻;每个桶数组用于存储与其对应的存储时段内的用户已浏览信息,任一桶数组对应的存储时段是根据该桶数组的创建时刻以及在该桶数组创建之后创建的第一个桶数组的创建时刻确定出的;The determining
获取模块402,用于获取目标用户已浏览的至少一个用户浏览信息,并确定每个用户浏览信息的浏览时刻;The obtaining
存储模块403,用于根据每个用户浏览信息的浏览时刻、每个桶数组的创建时刻以及每个桶数组对应的存储时段,将每个用户浏览信息对应存储在确定出的桶数组。The
作为一种可选的实施方式,存储模块403中根据每个用户浏览信息的浏览时刻、每个桶数组的创建时刻以及每个桶数组对应的存储时段,将每个用户浏览信息对应存储在确定出的桶数组的具体方式为:As an optional implementation, in the
对于每个用户浏览信息,根据每个桶数组对应的存储时段,从所有桶数组对应的存储时段中确定该用户浏览信息的浏览时刻所处的目标存储时段,并将目标存储时段对应的目标桶数组确定为与该用户浏览信息对应的目标桶数组;对于每个用户浏览信息,将该用户浏览信息存储至与该用户浏览信息对应的目标桶数组。For each user browsing information, according to the storage period corresponding to each bucket array, the target storage period at which the browsing moment of the user browsing information is located is determined from the storage periods corresponding to all bucket arrays, and the target bucket corresponding to the target storage period The array is determined as the target bucket array corresponding to the user browsing information; for each user browsing information, the user browsing information is stored in the target bucket array corresponding to the user browsing information.
作为一种可选的实施方式,确定模块401还用于确定待遍历的目标浏览信息唯一对应的标识信息;As an optional implementation manner, the determining
参阅图5是本发明实施例公开的另一种网络交互房间的下发装置的结构示意图,如图5所示,该装置还包括:Referring to FIG. 5, it is a schematic structural diagram of another device for delivering a network interactive room disclosed in an embodiment of the present invention. As shown in FIG. 5, the device further includes:
遍历模块404,从当前存在的所有桶数组中,按照创建时长由长到短的顺序依次从当前存在的所有桶数组中遍历标识信息对应的目标浏览信息,直至遍历到目标浏览信息或者当前存在的所有桶数组被遍历完毕;其中,目标浏览信息为待查询用户浏览信息或者待删除用户浏览信息。The
作为一种可选的实施方式,存储模块403中对于每个用户浏览信息,将该用户浏览信息存储在与该用户浏览信息对应的目标桶数组的具体方式为:As an optional implementation manner, for each user browsing information in the
对于每个用户浏览信息,确定该用户浏览信息对应的标识信息,并通过预置的散列函数对该用户浏览信息对应的标识信息进行散列,得到该用户浏览信息对应的散列值,以及确定该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置;对于每个用户浏览信息,将该用户浏览信息对应的散列值存储在与该用户浏览信息对应的目标桶数组中的存储位置。For each user browsing information, determine the identification information corresponding to the user browsing information, and hash the identification information corresponding to the user browsing information through a preset hash function to obtain a hash value corresponding to the user browsing information, and Determine the storage location of the hash value corresponding to the user browsing information in the target bucket array corresponding to the user browsing information; for each user browsing information, store the hash value corresponding to the user browsing information in the target bucket array corresponding to the user browsing information; The storage location in the corresponding target bucket array.
作为一种可选的实施方式,桶数组包括至少两个候选桶,存储模块403中对于每个用户浏览信息,确定该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置的具体方式为:As an optional implementation manner, the bucket array includes at least two candidate buckets, and for each user browsing information, the
对于每个用户浏览信息,通过预置的散列函数确定该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置,以及确定该用户浏览信息对应的散列值在对应的目标桶数组中的第二候选桶的存储位置;对于每个用户浏览信息,根据该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置的占用情况以及该用户浏览信息对应的散列值在对应的目标桶数组中的第二候选桶的存储位置的占用情况,确定该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置。For each user browsing information, the storage location of the first candidate bucket in the corresponding target bucket array of the hash value corresponding to the user browsing information is determined by a preset hash function, and the hash corresponding to the user browsing information is determined The storage location of the second candidate bucket whose value is in the corresponding target bucket array; for each user browsing information, the storage location of the first candidate bucket in the corresponding target bucket array is based on the hash value corresponding to the user browsing information. The occupancy status and the occupancy status of the hash value corresponding to the user's browsing information in the storage location of the second candidate bucket in the corresponding target bucket array, determine that the hash value corresponding to the user's browsing information is in the target corresponding to the user's browsing information The storage location in the bucket array.
作为一种可选的实施方式,存储模块403中对于每个用户浏览信息,根据该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置的占用情况以及该用户浏览信息对应的散列值在对应的目标桶数组中的第二候选桶的存储位置的占用情况,确定该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置的具体方式为:As an optional implementation manner, for each user browsing information in the
对于每个用户浏览信息,检测该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置是否被占用,并在检测到该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置没有被占用时,将该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置确定为该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置;对于每个用户浏览信息,在检测到该用户浏览信息对应的散列值在对应的目标桶数组中的第一候选桶的存储位置被占用时,将该用户浏览信息对应的散列值在对应的目标桶数组中的第二候选桶的存储位置确定为该用户浏览信息对应的散列值在与该用户浏览信息对应的目标桶数组中的存储位置。For each user browsing information, it is detected whether the storage location of the first candidate bucket in the corresponding target bucket array is occupied by the hash value corresponding to the user browsing information, and when it is detected that the hash value corresponding to the user browsing information is in When the storage location of the first candidate bucket in the corresponding target bucket array is not occupied, the storage location of the first candidate bucket in the corresponding target bucket array of the hash value corresponding to the user browsing information is determined as the user browsing information The storage location of the corresponding hash value in the target bucket array corresponding to the user's browsing information; for each user's browsing information, when it is detected that the hash value corresponding to the user's browsing information is the first in the corresponding target bucket array When the storage location of the candidate bucket is occupied, the storage location of the second candidate bucket in the corresponding target bucket array with the hash value corresponding to the user's browsing information is determined as the hash value corresponding to the user's browsing information is in the same location as the user's browsing information. The storage location in the target bucket array corresponding to the information.
作为一种可选的实施方式,确定模块402还用于根据当前时刻和每个桶数组的创建时刻,确定每个桶数组的创建时长;As an optional implementation manner, the determining
装置还包括:The device also includes:
比较模块405,用于对所有桶数组的创建时长中的最短创建时长和预置的第二预设时长进行比较,并最短创建时长大于第二预设时长时,创建新的桶数组并将待插入浏览信息存储至新的桶数组;对于每个桶数组,对该桶数组的创建时长和预置的第三预设时长进行比较,并在该桶数组的创建时长大于第三预设时长时,从所有桶数组中删除该桶数组。The
本发明实施例中,确定已创建的至少一个桶数组,并确定每个所述桶数组的创建时刻;每个所述桶数组用于存储与其对应的存储时段内的用户已浏览信息,任一所述桶数组对应的存储时段是根据该桶数组的创建时刻以及在该桶数组创建之后创建的第一个桶数组的创建时刻确定出的;获取目标用户已浏览的至少一个用户浏览信息,并确定每个所述用户浏览信息的浏览时刻;根据每个所述用户浏览信息的浏览时刻以及每个所述桶数组对应的存储时段,将每个所述用户浏览信息对应存储在确定出的所述桶数组。可见,实施本发明能够仅对用户浏览信息进行对应存储,节省了大量的存储空间,减少了存储成本。In this embodiment of the present invention, at least one bucket array that has been created is determined, and the creation time of each bucket array is determined; each bucket array is used to store the user's browsing information in its corresponding storage period, any one The storage period corresponding to the bucket array is determined according to the creation time of the bucket array and the creation time of the first bucket array created after the bucket array is created; obtain at least one user browsing information that the target user has browsed, and Determine the browsing time of each of the user browsing information; according to the browsing time of each of the user browsing information and the storage period corresponding to each of the bucket arrays, store each of the user browsing information in the determined array of buckets. It can be seen that by implementing the present invention, only user browsing information can be stored correspondingly, which saves a lot of storage space and reduces storage costs.
实施例四Embodiment 4
请参阅图6,图6是本发明实施例公开的又一种信息存储的装置的结构示意图。如图6所示,该信息存储的装置可以包括:Please refer to FIG. 6. FIG. 6 is a schematic structural diagram of another apparatus for information storage disclosed in an embodiment of the present invention. As shown in Figure 6, the information storage device may include:
存储有可执行程序代码的存储器501;a
与存储器501耦合的处理器502;a
处理器502调用存储器501中存储的可执行程序代码,执行本发明实施例一或本发明实施例二所描述的信息存储方法中的步骤。The
实施例五Embodiment 5
本发明实施例公开了一种计算机存储介质,该计算机存储介质存储有计算机指令,该计算机指令被调用时,用于执行本发明实施例一或本发明实施例二所描述的信息存储方法中的步骤。An embodiment of the present invention discloses a computer storage medium. The computer storage medium stores a computer instruction. When the computer instruction is called, it is used to execute the information storage method described in the first embodiment of the present invention or the second embodiment of the present invention. step.
实施例六Embodiment 6
本发明实施例公开了一种计算机程序产品,该计算机程序产品包括存储了计算机程序的非瞬时性计算机可读存储介质,且该计算机程序可操作来使计算机执行实施例一或实施例二中所描述的信息存储的方法中的步骤。An embodiment of the present invention discloses a computer program product. The computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute the first or second embodiment. Describes the steps in a method for information storage.
以上所描述的装置实施例仅是示意性的,其中所述作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理模块,即可以位于一个地方,或者也可以分布到多个网络模块上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性的劳动的情况下,即可以理解并实施。The device embodiments described above are only illustrative, wherein the modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in One place, or it can be distributed over multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution in this embodiment. Those of ordinary skill in the art can understand and implement it without creative effort.
通过以上的实施例的具体描述,本领域的技术人员可以清楚地了解到各实施方式可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件。基于这样的理解,上述技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在计算机可读存储介质中,存储介质包括只读存储器(Read-Only Memory,ROM)、随机存储器(Random Access Memory,RAM)、可编程只读存储器(Programmable Read-only Memory,PROM)、可擦除可编程只读存储器(ErasableProgrammable Read Only Memory,EPROM)、一次可编程只读存储器(One-timeProgrammable Read-Only Memory,OTPROM)、电子抹除式可复写只读存储器(Electrically-Erasable Programmable Read-Only Memory,EEPROM)、只读光盘(CompactDisc Read-Only Memory,CD-ROM)或其他光盘存储器、磁盘存储器、磁带存储器、或者能够用于携带或存储数据的计算机可读的任何其他介质。From the specific description of the above embodiments, those skilled in the art can clearly understand that each implementation manner can be implemented by means of software plus a necessary general hardware platform, and certainly can also be implemented by means of hardware. Based on such understanding, the above-mentioned technical solutions can be embodied in the form of software products in essence or that make contributions to the prior art. The computer software products can be stored in a computer-readable storage medium, and the storage medium includes a read-only memory. (Read-Only Memory, ROM), Random Access Memory (Random Access Memory, RAM), Programmable Read-only Memory (Programmable Read-only Memory, PROM), Erasable Programmable Read Only Memory (Erasable Programmable Read Only Memory, EPROM) , One-time Programmable Read-Only Memory (OTPROM), Electronically-Erasable Programmable Read-Only Memory (EEPROM), CompactDisc Read-Only Memory , CD-ROM) or other optical disk storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.
最后应说明的是:本发明实施例公开的一种信息存储方法及装置所揭露的仅为本发明较佳实施例而已,仅用于说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解;其依然可以对前述各项实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或替换,并不使相应的技术方案的本质脱离本发明各项实施例技术方案的精神和范围。Finally, it should be noted that the information storage method and device disclosed in the embodiments of the present invention are only preferred embodiments of the present invention, and are only used to illustrate the technical solutions of the present invention, not to limit them; although refer to The foregoing embodiments have described the present invention in detail, and those of ordinary skill in the art should understand that; it is still possible to modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements to some of the technical features; and these modifications Or replacement, does not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111677190.7A CN114357302B (en) | 2021-12-31 | 2021-12-31 | A method and device for storing information |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111677190.7A CN114357302B (en) | 2021-12-31 | 2021-12-31 | A method and device for storing information |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114357302A true CN114357302A (en) | 2022-04-15 |
CN114357302B CN114357302B (en) | 2025-06-27 |
Family
ID=81104556
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111677190.7A Active CN114357302B (en) | 2021-12-31 | 2021-12-31 | A method and device for storing information |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114357302B (en) |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5307263A (en) * | 1992-11-17 | 1994-04-26 | Raya Systems, Inc. | Modular microprocessor-based health monitoring system |
US20140358636A1 (en) * | 2013-05-30 | 2014-12-04 | Michael Nowak | Survey segmentation |
CN107273397A (en) * | 2016-03-31 | 2017-10-20 | 三星电子株式会社 | The many Hash tables of virtual bucket for the online deduplication application of effective memory |
CN109615465A (en) * | 2018-11-22 | 2019-04-12 | 阿里巴巴集团控股有限公司 | Processing method, device and the electronic equipment of service order |
CN110781386A (en) * | 2019-10-10 | 2020-02-11 | 支付宝(杭州)信息技术有限公司 | Information recommendation method and device, and bloom filter creation method and device |
CN111782872A (en) * | 2020-06-30 | 2020-10-16 | 北京百度网讯科技有限公司 | Query method, query device, electronic equipment and storage medium |
CN112486915A (en) * | 2020-12-18 | 2021-03-12 | 上海哔哩哔哩科技有限公司 | Data storage method and device |
CN113366469A (en) * | 2019-06-29 | 2021-09-07 | 深圳市欢太科技有限公司 | Data classification method and related product |
-
2021
- 2021-12-31 CN CN202111677190.7A patent/CN114357302B/en active Active
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5307263A (en) * | 1992-11-17 | 1994-04-26 | Raya Systems, Inc. | Modular microprocessor-based health monitoring system |
US20140358636A1 (en) * | 2013-05-30 | 2014-12-04 | Michael Nowak | Survey segmentation |
CN107273397A (en) * | 2016-03-31 | 2017-10-20 | 三星电子株式会社 | The many Hash tables of virtual bucket for the online deduplication application of effective memory |
CN109615465A (en) * | 2018-11-22 | 2019-04-12 | 阿里巴巴集团控股有限公司 | Processing method, device and the electronic equipment of service order |
CN113366469A (en) * | 2019-06-29 | 2021-09-07 | 深圳市欢太科技有限公司 | Data classification method and related product |
CN110781386A (en) * | 2019-10-10 | 2020-02-11 | 支付宝(杭州)信息技术有限公司 | Information recommendation method and device, and bloom filter creation method and device |
CN111782872A (en) * | 2020-06-30 | 2020-10-16 | 北京百度网讯科技有限公司 | Query method, query device, electronic equipment and storage medium |
CN112486915A (en) * | 2020-12-18 | 2021-03-12 | 上海哔哩哔哩科技有限公司 | Data storage method and device |
Non-Patent Citations (1)
Title |
---|
张建宇 等: "PaSeM:并行无冲突的网络流量会话管理", 计算机学报, no. 07, 15 July 2010 (2010-07-15), pages 83 - 100 * |
Also Published As
Publication number | Publication date |
---|---|
CN114357302B (en) | 2025-06-27 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8176061B2 (en) | Tracking digital assets on a distributed network | |
JP5506290B2 (en) | Associative memory system and method using searchable blocks | |
CN107783770B (en) | Page configuration updating method, device, server and medium | |
CN107911461B (en) | Object processing method in cloud storage system, storage server and cloud storage system | |
WO2020211236A1 (en) | Read-write conflict resolution method and apparatus employing b+ tree and storage medium | |
CN110888837B (en) | Object storage small file merging method and device | |
CN105373595B (en) | A kind of data self-classification storage method and terminal | |
CN108228799B (en) | Object index information storage method and device | |
CN111444192B (en) | Method, device and equipment for generating Hash of global state in block chain type account book | |
CN110569218B (en) | Offline modification method and device for EXT file system and storage medium | |
CN110543575B (en) | Media file retrieval method and device of vehicle-mounted external storage equipment | |
CN106899879A (en) | A kind for the treatment of method and apparatus of multi-medium data | |
CN107066588A (en) | A kind of database and corresponding method and apparatus | |
CN114357302A (en) | A method and device for storing information | |
CN113448946A (en) | Data migration method and device and electronic equipment | |
CN111698330B (en) | Data recovery method and device of storage cluster and server | |
TWI420333B (en) | A distributed de-duplication system and the method therefore | |
CN107526840A (en) | File system snapshot querying method, device and computer-readable recording medium | |
CN117540062A (en) | Retrieval model recommendation method and device based on knowledge graph | |
CN113448929A (en) | Data storage method and device, equipment and storage medium | |
CN106874486A (en) | Method and mobile terminal that a kind of Folder Name shows | |
CN103886028A (en) | Method and apparatus for copying files from storage device to advertisement machine | |
EP2164005B1 (en) | Content addressable storage systems and methods employing searchable blocks | |
CN105630991A (en) | Method and device for automatically generating ID | |
CN104298768A (en) | Searching method, device and system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |