CN114051162B - Caching method and device based on play records - Google Patents

Caching method and device based on play records Download PDF

Info

Publication number
CN114051162B
CN114051162B CN202210029420.7A CN202210029420A CN114051162B CN 114051162 B CN114051162 B CN 114051162B CN 202210029420 A CN202210029420 A CN 202210029420A CN 114051162 B CN114051162 B CN 114051162B
Authority
CN
China
Prior art keywords
dictionary
video
video identifier
identifier
exists
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.)
Active
Application number
CN202210029420.7A
Other languages
Chinese (zh)
Other versions
CN114051162A (en
Inventor
刘其政
孙成新
王金明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Feihu Information Technology Tianjin Co Ltd
Original Assignee
Feihu Information Technology Tianjin Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Feihu Information Technology Tianjin Co Ltd filed Critical Feihu Information Technology Tianjin Co Ltd
Priority to CN202210029420.7A priority Critical patent/CN114051162B/en
Publication of CN114051162A publication Critical patent/CN114051162A/en
Application granted granted Critical
Publication of CN114051162B publication Critical patent/CN114051162B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/433Content storage operation, e.g. storage operation in response to a pause request, caching operations
    • H04N21/4334Recording operations
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/433Content storage operation, e.g. storage operation in response to a pause request, caching operations
    • H04N21/4331Caching operations, e.g. of an advertisement for later insertion during playback
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/47End-user applications
    • H04N21/472End-user interface for requesting content, additional data or services; End-user interface for interacting with content, e.g. for content reservation or setting reminders, for requesting event notification, for manipulating displayed content
    • H04N21/47217End-user interface for requesting content, additional data or services; End-user interface for interacting with content, e.g. for content reservation or setting reminders, for requesting event notification, for manipulating displayed content for controlling playback functions for recorded or on-demand content, e.g. using progress bars, mode or play-point indicators or bookmarks

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Databases & Information Systems (AREA)
  • Human Computer Interaction (AREA)
  • Television Signal Processing For Recording (AREA)
  • Management Or Editing Of Information On Record Carriers (AREA)

Abstract

The invention provides a caching method and a caching device based on a play record, which are used for judging whether a first album mark exists in a received first play record or not; if the first album mark does not exist, updating the play list and the first dictionary by using the first video mark in the first play record; if the first album mark exists, judging whether a second video mark corresponding to the first album mark exists in a second dictionary or not; if the second video identifier exists, deleting contents related to the second video identifier in the playlist, the first dictionary and the second dictionary; updating the second dictionary, the playlist and the first dictionary with the first video identifier; and if the second video identifier does not exist, updating the second dictionary, the playlist and the first dictionary by using the first video identifier. By adopting the cache mode, when a certain play record is processed, the required data can be directly acquired from the play list and/or the dictionary, the efficiency of processing the play record is effectively improved, the time complexity is reduced, and the occupied resources are reduced.

Description

Caching method and device based on play records
Technical Field
The invention relates to the technical field of multimedia caching, in particular to a caching method and device based on play records.
Background
In the video website, when a user watches videos, corresponding video playing progress can be generated, and the video website can record the video playing progress so that the user can continue playing at a breakpoint.
Currently, all video playing records are stored in a cloud cache in a list form. Under the condition that all video playing records are stored in one list, when a certain video playing record needs to be processed (such as addition, modification, deletion or positioning), the list for storing the video playing record needs to be read from the cloud cache, and the video playing record needing to be processed can be found only by traversing the whole list.
Disclosure of Invention
In view of this, embodiments of the present invention provide a buffering method and apparatus based on a play record, so as to solve the problems that the existing video play record storage manner may generate higher resource overhead and higher time complexity when processing a video play record.
In order to achieve the above purpose, the embodiments of the present invention provide the following technical solutions:
the first aspect of the embodiments of the present invention discloses a cache method based on a play record, where the method includes:
when a first play record at least carrying a first video identifier is received, judging whether a first album identifier exists in the first play record;
if the first album identification does not exist, executing an updating step;
if the first album identification exists, judging whether a second video identification corresponding to the first album identification exists in a second dictionary, wherein the second dictionary comprises video identifications and album identifications with corresponding relations;
if the second video identifier exists in the second dictionary, deleting contents related to the second video identifier from a playlist, a first dictionary and the second dictionary, wherein the playlist comprises a plurality of video identifiers, and the first dictionary comprises video identifiers and play records which have corresponding relations;
storing the first album identification and the first video identification to the second dictionary, and performing the updating step;
if the second video identifier does not exist in the second dictionary, storing the first video identifier and the first album identifier to the second dictionary, and executing the updating step;
the updating step includes:
and updating the playlist according to the first video identifier, and updating the first dictionary according to the first video identifier and a first play record.
Preferably, the updating the playlist according to the first video identifier includes:
judging whether the first video identifier exists in the playlist or not;
if the first video identifier exists in the playlist, adjusting the storage position of the first video identifier in the playlist by using the reporting time of the first playing record;
and if the first video identifier does not exist in the play list, storing the first video identifier into the play list according to the reporting time of the first play record.
Preferably, the updating the first dictionary according to the first video identifier and the first play record includes:
judging whether the first video identifier exists in the first dictionary or not;
if the first video identifier exists in the first dictionary, replacing the first playing record with the playing record corresponding to the first video identifier in the first dictionary;
and if the first video identifier does not exist in the first dictionary, storing the first video identifier and the first play record to the first dictionary.
Preferably, the method further comprises:
when a search instruction for searching for a play record corresponding to a third video identifier is received, judging whether the third video identifier exists in the first dictionary, wherein the third video identifier is carried by the search instruction, or the third video identifier is obtained by inquiring from the second dictionary according to a second album identifier carried by the search instruction;
and if the third video identifier exists, acquiring a play record corresponding to the third video identifier from the first dictionary.
Preferably, the method further comprises:
when a deletion instruction for deleting a play record corresponding to a fourth video identifier is received, searching whether the fourth video identifier exists in the play list;
when the fourth video identifier exists in the playlist, deleting the fourth video identifier from the playlist;
searching whether the fourth video identification exists in the first dictionary or not;
when the fourth video identification exists in the first dictionary, deleting the fourth video identification and the playing record corresponding to the fourth video identification from the first dictionary;
searching whether the fourth video identification exists in the second dictionary or not;
and when the fourth video identification exists in the second dictionary, deleting the fourth video identification and the album identification corresponding to the fourth video identification from the second dictionary.
Preferably, the deleting the content related to the second video identifier from the playlist, the first dictionary and the second dictionary includes:
and deleting the second video identifier from a playlist, deleting the second video identifier and a play record corresponding to the second video identifier from a first dictionary, and deleting the second video identifier and the first album identifier from the second dictionary.
A second aspect of the present invention discloses a buffer device based on a play record, where the device includes:
the first judging unit is used for judging whether a first album identifier exists in a first play record or not when the first play record at least carrying a first video identifier is received; if the first album mark does not exist, executing an updating unit; if the first album mark exists, executing a second judgment unit;
the second judging unit is configured to judge whether a second video identifier corresponding to the first album identifier exists in a second dictionary, where the second dictionary includes video identifiers and album identifiers having a corresponding relationship; if the second video identifier exists in the second dictionary, executing a processing unit; if the second video identifier does not exist in the second dictionary, executing a storage unit;
the processing unit is configured to delete content related to the second video identifier from a playlist, a first dictionary, and the second dictionary, where the playlist includes a plurality of video identifiers, and the first dictionary includes video identifiers and play records having a corresponding relationship; storing the first album identification and the first video identification to the second dictionary, and executing the updating unit;
the storage unit is used for storing the first video identifier and the first album identifier to the second dictionary and executing the updating unit;
and the updating unit is used for updating the playlist according to the first video identifier and updating the first dictionary according to the first video identifier and the first playing record.
Preferably, the update unit includes:
the first updating module is used for judging whether the first video identifier exists in the playlist or not; if the first video identifier exists in the playlist, adjusting the storage position of the first video identifier in the playlist by using the reporting time of the first playing record; and if the first video identifier does not exist in the play list, storing the first video identifier into the play list according to the reporting time of the first play record.
Preferably, the update unit includes:
the second updating module is used for judging whether the first video identifier exists in the first dictionary or not; if the first video identifier exists in the first dictionary, replacing the first playing record with the playing record corresponding to the first video identifier in the first dictionary; and if the first video identifier does not exist in the first dictionary, storing the first video identifier and the first play record to the first dictionary.
Preferably, the apparatus further comprises:
the searching unit is used for judging whether the third video identifier exists in the first dictionary or not when a searching instruction for searching for a playing record corresponding to the third video identifier is received, wherein the third video identifier is carried by the searching instruction, or the third video identifier is obtained by inquiring from the second dictionary according to a second album identifier carried by the searching instruction; and if the third video identifier exists, acquiring a play record corresponding to the third video identifier from the first dictionary.
Based on the above-mentioned caching method and device based on the play record provided by the embodiment of the present invention, the method is: when a first play record at least carrying a first video identifier is received, judging whether a first album identifier exists in the first play record; if the first album identifier does not exist, updating the playlist and the first dictionary; if the first album identification exists, judging whether a second video identification corresponding to the first album identification exists in a second dictionary or not; if the second video identifier exists, deleting the content related to the second video identifier from the playlist, the first dictionary and the second dictionary; updating the second dictionary, the playlist and the first dictionary; and if the second video identifier does not exist in the second dictionary, updating the second dictionary, the playlist and the first dictionary. The play records are stored by utilizing the play list, the first dictionary and the second dictionary, and by adopting the cache mode, when a certain play record is processed, required data can be directly acquired from the play list and/or the dictionary, so that the efficiency of processing the play record is effectively improved, the time complexity is reduced, and occupied resources are reduced.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
Fig. 1 is a flowchart of a caching method based on a play record according to an embodiment of the present invention;
fig. 2 is a schematic diagram illustrating a relationship between a video identifier and an album identifier in a second dictionary according to an embodiment of the present invention;
fig. 3 is a schematic diagram illustrating a relationship between video identifiers and play records in a first dictionary according to an embodiment of the present invention;
fig. 4 is a schematic diagram illustrating a storage form of video identifiers in a playlist according to an embodiment of the present invention;
FIG. 5 is a flowchart of updating a playlist according to a first video identifier according to an embodiment of the present invention;
fig. 6 is a flowchart of updating a first dictionary according to a first video identifier and a first play record according to an embodiment of the present invention;
fig. 7 is a block diagram of a buffer apparatus based on play records according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In this application, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
As can be seen from the background art, in the conventional method for storing video playing records, when a certain video playing record needs to be processed (such as addition, modification, deletion, or positioning), a list for storing the video playing record needs to be read from the cloud cache, and the video playing record needing to be processed can be found only by traversing the whole list.
Therefore, an embodiment of the present invention provides a caching method and apparatus based on a play record, where when a first play record carrying a first video identifier is received, whether the first play record has a first album identifier is searched for; when the first album identifier exists in the first play record, searching whether a second video identifier corresponding to the first album identifier exists in a second dictionary, if the second video identifier corresponding to the first album identifier exists in the second dictionary, deleting contents related to the second video identifier in the playlist, the first dictionary and the second dictionary, and updating the playlist, the first dictionary and the second dictionary according to the first video identifier; if the second dictionary does not have a second video identifier corresponding to the first album identifier, the playlist, the first dictionary and the second dictionary are directly updated according to the first video identifier; when the first album identification is not in the first play record, the playlist, the first dictionary and the second dictionary are also directly updated according to the first video identification. By the method for storing the play records in the playlist, the first dictionary and the second dictionary, when the play records need to be processed, required data can be quickly inquired from the playlist and/or the dictionary, the time complexity is O (1) level, the whole playlist does not need to be traversed, and therefore the efficiency of processing the play records can be effectively improved, fewer resources need to be occupied when the play records are processed, and the time complexity is effectively reduced.
Referring to fig. 1, a flowchart of a caching method based on a play record according to an embodiment of the present invention is shown, where the caching method includes:
step S101: when a first play record carrying at least a first video identifier is received, whether a first album identifier exists in the first play record is judged. If the first album identification exists in the first play record, executing step S102; if the first album flag does not exist in the first play record, go to step S105.
It can be understood that, when the user watches the video, the video website will periodically trigger the report of the play record according to a preset time (e.g. 10 seconds), that is, record the progress of the user watching the video. When a first play record carrying at least a first video identifier is received, indicating that the content in the first play record needs to be stored.
It should be noted that, according to the characteristics of the play records, only the latest play record is reserved in the same video or the same album, so that when the first play record is received, it is necessary to determine whether the video corresponding to the first play record belongs to a certain album, so as to query whether the video website has stored the play records of other videos that belong to the same album and correspond to the first play record.
It can be understood that the content carried in the play record may be content agreed by the client and the server (e.g., a user identifier id, a video identifier vid, an album identifier aid, a viewing duration viewTime, how many seconds to view, etc.).
Step S102: and judging whether a second video identifier corresponding to the first album identifier exists in the second dictionary. If the second dictionary has the second video identifier, executing step S103; if the second dictionary does not have the second video identifier, step S104 is executed.
It should be noted that the second dictionary is used for storing video identifiers and album identifiers having corresponding relationships, such as: and the video a belongs to the album A, the video identifier of the video a is a, the album identifier of the album A is A, and the video identifier a and the album identifier A are stored in a second dictionary. The second dictionary may store the data through a hash algorithm when storing the data. The second dictionary may be constructed by using a map structure of a redis database, in which a field key and a value having a correspondence relationship are stored, where a value stored in the field key is not allowed to be repeated, and a value stored in the value may be repeated. Wherein the album is identified as a field key; the video is identified as the value. In the second dictionary, one album id corresponds to one video id, and the relationship between the video id and the album id in the second dictionary is shown in fig. 2, it should be noted that the content shown in fig. 2 is only an example of the relationship between the video id vid and the album id aid, different $ { aid } in fig. 2 all refer to different album ids, and different $ { vid } all refer to different video ids.
In the process of implementing step S102 specifically, when the first album identifier exists in the first play record, it is determined whether the second video identifier exists in the second dictionary, that is, it is determined whether the video corresponding to the first play record and the video identifiers corresponding to other videos belonging to the same album exist in the second dictionary. When the second video identifier exists in the second dictionary, executing step S103; when the second video identifier does not exist in the second dictionary, step S104 is performed.
It can be understood that when a second video identifier exists in the second dictionary, it indicates that a video corresponding to the first play record and video identifiers corresponding to other videos belonging to the same album exist in the second dictionary; and when the second video identifier does not exist in the second dictionary, indicating that the video corresponding to the first playing record and the video identifiers corresponding to other videos belonging to the same album are not stored in the second dictionary.
Step S103: the content associated with the second video identity is deleted from the playlist, the first dictionary and the second dictionary and step S104 is performed.
It should be noted that, the first dictionary stores video identifiers and play records having corresponding relationships, for example: and the video identifier B belongs to the play record B, and the video identifier B and the play record B are stored in the first dictionary. The first dictionary may store data through a hash algorithm when storing the data. The first dictionary may also be constructed by adopting a map structure of a redis database, so that the first dictionary contains a video identifier having a corresponding relationship and a play record corresponding to the video identifier. The video identifier is a field key, and the playing record corresponding to the video identifier is a value. In the first dictionary, one video identifier corresponds to one play record, and a relationship between the video identifier and the play record in the first dictionary is shown in fig. 3, it should be noted that the content shown in fig. 3 is only an example of a relationship between a video identifier vid and a play record, different $ { vid } in fig. 3 refer to different video identifiers, and each video identifier corresponds to one play record (including vid, aid, Point, viewTime, and the like).
It will be appreciated that the playlist is used to store the video identifiers viewed by the user and may be constructed in the form of zset in the redis database, where zset is a set that does not allow elements to be repeated, and each element in the set is associated with a score of double type, and the elements in the set are sorted by the scores in order from small to large.
Therefore, the playlist contains a plurality of video identifiers, the reporting time corresponding to the video identifiers is used as a score, and the video identifiers are sorted according to the corresponding reporting time in the order from small to large. The storage form of the video identifier in the playlist is shown in fig. 4, it should be noted that the content shown in fig. 4 is only a storage example of the video identifier vid, and different $ { vid } in fig. 4 all refer to different video identifiers.
In the process of implementing step S103 specifically, when there is a second video identifier in the second dictionary, according to the feature that only the latest play record is reserved, the content related to the second video identifier needs to be deleted from the playlist, the first dictionary, and the second dictionary, and then step S104 is executed.
It is understood that the deletion of the content associated with the second video identification from the play record is: deleting the second video identification from the playlist; the content related to the second video identifier is deleted from the first dictionary as follows: deleting the second video identifier and the playing record corresponding to the second video identifier from the first dictionary; the content related to the second video identifier is deleted from the second dictionary as follows: the second video identification and the first album identification are deleted from the second dictionary.
Step S104: and storing the first album identification and the first video identification to a second dictionary.
In the process of implementing step S104 specifically, after deleting the content related to the second video identifier from the playlist, the first dictionary and the second dictionary, or when the second video identifier does not exist in the second dictionary, the first album identifier and the first video identifier having the corresponding relationship are stored in the second dictionary.
Step S105: and updating the playlist according to the first video identifier, and updating the first dictionary according to the first video identifier and the first play record.
In the process of implementing step S105 specifically, when the first album identifier does not exist in the first play record, or after the first album identifier and the first video identifier are stored in the second dictionary, the position of the first video identifier in the playlist is updated according to the reporting time corresponding to the first video identifier, and the first dictionary is updated according to the first video identifier and the first play record.
It should be noted that, the details of the specific implementation process for updating the playlist according to the first video identifier are shown in fig. 5 in the following embodiment of the present invention; the specific implementation process of updating the first dictionary according to the first video identifier and the first play record is described in detail in fig. 6 in the following embodiment of the present invention.
The contents of the above steps are related contents for storing the contents of the playing records into the playlist, the first dictionary and the second dictionary; after the play records are stored in this way, when a play record needs to be searched or deleted, the play record can be searched or deleted from the playlist, the first dictionary and the second dictionary, which will be described in detail below.
It is understood that the search instruction for searching the play record corresponding to the third video identifier may be triggered by the user, for example, when the user enters an album (e.g., an episode) interface, the last watched video (e.g., the number of episodes of the episode) and the viewing progress may be shown to the user.
Preferably, the process of searching for the play record corresponding to the third video identifier from the first dictionary comprises:
it should be noted that when a user searches for a play record corresponding to a certain video identifier, there are two search situations, the first search situation is that the user directly clicks the video, and at this time, a search instruction carries a third video identifier corresponding to the video; the second search condition is that the user clicks the album (or the episode) corresponding to the video, and at this time, the search instruction carries the second album identifier corresponding to the video;
and for the first searching condition, when the searching instruction carries a third video identifier corresponding to the video clicked by the user, judging whether the third video identifier exists in the first dictionary or not. If the third video identifier exists in the first dictionary, acquiring a play record corresponding to the third video identifier from the first dictionary; and if the third video identification does not exist in the first dictionary, no operation is performed.
For a second search condition, when a search instruction carries a second album identifier corresponding to a video, a third video identifier corresponding to the second album identifier is obtained from the second dictionary, and then whether the third video identifier exists in the first dictionary is searched. If the third video identifier exists in the first dictionary, acquiring a play record corresponding to the third video identifier from the first dictionary; and if the third video identification does not exist in the first dictionary, no operation is performed.
It can be understood that the first dictionary is stored by using a hash algorithm when the data is stored, so that the first dictionary can be searched by using the hash algorithm when the third video identifier is inquired whether or not the first dictionary exists, and the whole first dictionary does not need to be traversed.
It should be noted that the deletion instruction for deleting the play record corresponding to the fourth video identifier may be triggered by a user or may be triggered by a program (for example, the reason why the video or album has failed, the copyright expires, or the like).
Preferably, the process of deleting the play record corresponding to the fourth video identifier from the playlist, the first dictionary and the second dictionary is as follows:
and when a deletion instruction for deleting the playing record corresponding to the fourth video identifier is received, searching whether the fourth video identifier exists in the playing list or not. If the fourth video identifier exists in the playlist, deleting the fourth video identifier from the playlist; and if the fourth video identifier does not exist in the playlist, searching whether the fourth video identifier exists in the first dictionary or not.
And when the fourth video identifier does not exist in the playlist or after the fourth video identifier is deleted from the playlist, searching whether the fourth video identifier exists in the first dictionary or not. When the fourth video identification exists in the first dictionary, deleting the fourth video identification and the playing record corresponding to the fourth video identification from the first dictionary; and when the fourth video identifier does not exist in the first dictionary, searching whether the fourth video identifier exists in the second dictionary or not.
And when the fourth video identifier does not exist in the first dictionary, or after the fourth video identifier and the playing record corresponding to the fourth video identifier are deleted from the first dictionary, searching whether the fourth video identifier exists in the second dictionary or not. If the fourth video identification exists in the second dictionary, deleting the fourth video identification and the album identification corresponding to the fourth video identification from the second dictionary; and if the fourth video identifier does not exist in the second dictionary, no operation is performed.
It should be noted that, the order of searching for and deleting the content related to the fourth video identifier in the playlist, the first dictionary, and the second dictionary provided in the embodiment of the present invention is only used for example, and the processing order may also be processing the first dictionary first, processing the playlist second, and processing the second dictionary last, where the processing order is not particularly limited, and may be set by an actual situation.
In the embodiment of the invention, the map structure of the database redis applied, the first dictionary and the second dictionary are constructed, and the play list with zset set characteristics is constructed, so that the storage and play records are more organized. When a certain play record needs to be stored, searched or deleted, the required data can be directly positioned according to the Hash algorithm, the time complexity is O (1) level, the operation is more convenient and fast, and the efficiency of processing the play record is improved.
Referring to fig. 5, the specific implementation process related to the present invention for updating a playlist according to a first video identifier is shown in the specific implementation process for updating a playlist according to a first video identifier, which includes the following steps:
step S501: and judging whether the first video identifier exists in the playlist. If the first video identifier exists in the playlist, executing step S502; if the first video identifier does not exist in the playlist, go to step S503.
In the process of implementing step S501 specifically, it is determined whether a first video identifier exists in the playlist, and when the first video identifier exists in the playlist, the user is instructed to watch the video corresponding to the first video identifier, and since the first play record is a newly uploaded play record, the storage position of the first video identifier in the playlist needs to be adjusted, and step S502 is executed; when the first video identifier does not exist in the playlist, step S503 is performed.
Step S502: and adjusting the storage position of the first video identifier in the playlist by using the reporting time of the first play record.
In the process of implementing step S502 specifically, when the first video identifier exists in the playlist, the reporting time of the first play record is used to replace the original reporting time corresponding to the first video identifier in the playlist, a new storage location of the first video identifier in the playlist is determined according to the reporting time of the first play record, and the first video identifier is moved to the new storage location.
It can be understood that, because the playlist adopts a zset structure of the database redis, the position of the first video identifier in the playlist can be automatically maintained according to the reporting time of the first play record.
For example: the playlist stores: the corresponding reporting time of the video identifier A is 1 minute and 30 seconds; the corresponding reporting time of the video identifier B is 2 minutes and 30 seconds; and the corresponding reporting time of the video identifier C is 3 minutes and 30 seconds. The existing newly uploaded first play record carries the video identifier a, and the corresponding reporting time is 5 minutes and 30 seconds.
At this time, the corresponding reporting time of the video identifier a in the playlist needs to be changed from 1 minute and 30 seconds to 5 minutes and 30 seconds, and the position of the video identifier a in the playlist is adjusted, where the data in the adjusted playlist is: the corresponding reporting time of the video identifier B is 2 minutes and 30 seconds; the corresponding reporting time of the video identifier C is 3 minutes and 30 seconds; and the corresponding reporting time of the video identifier A is 5 minutes and 30 seconds.
Step S503: and storing the first video identifier into a play list according to the reporting time of the first play record.
In the process of implementing step S503 specifically, when the first video identifier does not exist in the playlist, determining a storage location of the first video identifier in the playlist according to the reporting time of the first play record, and storing the first video identifier in the storage location.
For example: the playlist stores: the corresponding reporting time of the video identifier A is 1 minute and 30 seconds; the corresponding reporting time of the video identifier B is 2 minutes and 30 seconds; and the corresponding reporting time of the video identifier C is 3 minutes and 30 seconds. The existing newly uploaded first playing record carries the video identifier D, and the corresponding reporting time is 4 minutes and 50 seconds.
At this time, the video identifier D needs to be stored in the playlist according to the reporting time corresponding to the video identifier D, and after the storage is completed, the data in the playlist are: the corresponding reporting time of the video identifier A is 1 minute and 30 seconds; the corresponding reporting time of the video identifier B is 2 minutes and 30 seconds; the corresponding reporting time of the video identifier C is 3 minutes and 30 seconds; and the corresponding reporting time of the video identifier D is 4 minutes and 50 seconds.
In the embodiment of the invention, the playlist is updated by using the reporting time of the first play record according to the first video identifier. When the first video identifier exists in the playlist, replacing the reporting time corresponding to the original first video identifier in the playlist by using the reporting time of the first playing record, and adjusting the storage position of the first video identifier in the playlist; and when the first video identifier does not exist in the playlist, determining the storage position of the first video identifier in the playlist according to the reporting time of the first play record, and storing the first video identifier to the storage position. Based on the characteristics of the zset structure of the database redis, the method realizes automatic maintenance of the sequence of the video identifiers in the playlist, and effectively reduces the maintenance cost and the error rate of data compared with the original method of manually maintaining the sequence of the video identifiers in the playlist.
Referring to fig. 6, a specific implementation process related to the updating of the first dictionary according to the first video identifier and the first play record according to the present invention is shown in the specific implementation process of updating the first dictionary according to the first video identifier and the first play record provided in the embodiment of the present invention, and includes the following steps:
step S601: and judging whether the first dictionary has the first video identification. If the first dictionary has the first video identifier, step S602; if the first dictionary does not have the first video identifier, step S603 is executed.
In the process of implementing step S601 specifically, it is determined whether a first video identifier exists in the first dictionary, and when the first video identifier exists in the first dictionary, a play record corresponding to the first video in the first dictionary needs to be updated, and step S602 is executed; when the first video identifier does not exist in the first dictionary, step S603 is performed.
Step S602: and replacing the playing record corresponding to the first video identifier in the first dictionary with the first playing record.
In the process of implementing step S602 specifically, when the first video identifier exists in the first dictionary, it indicates that an original play record corresponding to the first video identifier exists, and replaces the original play record in the first dictionary with the first play record, that is, the first play record covers the original play record corresponding to the first video identifier in the first dictionary.
Step S603: and storing the first video identifier and the first play record to a first dictionary.
In the process of implementing step S603 specifically, when the first video identifier does not exist in the first dictionary, the first video identifier and the first play record having the corresponding relationship are stored in the first dictionary.
In an embodiment of the present invention, the first dictionary is updated with the first video identification and the first play record. The first dictionary adopts a map structure of a database redis, the whole first dictionary does not need to be traversed when the first video identifier exists in the first dictionary, the first video identifier can be directly searched in the first dictionary according to a Hash algorithm, and therefore follow-up operation is carried out, the time complexity is O (1) level, compared with the storage mode of storing all playing records in the original play list, the mode effectively reduces the time complexity and accelerates the speed of processing the playing records.
Corresponding to the above-mentioned caching method based on the play record provided by the embodiment of the present invention, referring to fig. 7, an embodiment of the present invention further provides a structural block diagram of a caching apparatus based on the play record, where the caching apparatus includes: first determining section 701, second determining section 702, processing section 703, storage section 704, and updating section 705:
a first determining unit 701, configured to determine whether a first album identifier exists in a first play record when the first play record carrying at least a first video identifier is received; if the first album id does not exist, the update unit 705 is executed; if the first album flag exists, the second determination unit 702 is executed.
A second determining unit 702, configured to determine whether a second dictionary has a second video identifier corresponding to the first album identifier, where the second dictionary includes video identifiers and album identifiers having a corresponding relationship; if the second dictionary has the second video identifier, the processing unit 703 is executed; if the second dictionary does not have the second video identifier, the storage unit 704 is executed.
A processing unit 703, configured to delete content related to the second video identifier from a playlist, a first dictionary and a second dictionary, where the playlist includes a plurality of video identifiers, and the first dictionary includes video identifiers and play records having corresponding relationships; the first album identification and the first video identification are stored to the second dictionary, and the updating unit 705 is executed.
A storage unit 704, configured to store the first video identifier and the first album identifier in the second dictionary, and execute the updating unit 705.
The updating unit 705 is configured to update the playlist according to the first video identifier, and update the first dictionary according to the first video identifier and the first play record.
In the embodiment of the invention, the play records are stored by utilizing the play list, the first dictionary and the second dictionary, and by adopting the storage mode, when the play records are required to be processed, required data can be directly inquired without traversing the whole first dictionary and the whole second dictionary, so that the time complexity for processing the play records is reduced to O (1) level, the efficiency for processing the play records is improved, and simultaneously, the resources required to be occupied for processing the play records are reduced.
Preferably, in conjunction with the content shown in fig. 7, the updating unit 705 includes: the system comprises a first updating module and a second updating module, wherein the execution principle of each module is as follows:
the first updating module is used for judging whether a first video identifier exists in the playlist or not; if the first video identifier exists in the playlist, adjusting the storage position of the first video identifier in the playlist by using the reporting time of the first playing record; and if the first video identifier does not exist in the playlist, storing the first video identifier into the playlist according to the reporting time of the first play record.
The second updating module is used for judging whether the first dictionary has the first video identifier or not; if the first dictionary has the first video identifier, replacing the first playing record with the playing record corresponding to the first video identifier in the first dictionary; and if the first dictionary does not have the first video identifier, storing the first video identifier and the first playing record into the first dictionary.
Preferably, in combination with the content shown in fig. 7, the caching apparatus further includes: a search unit and a deletion unit:
the searching unit is used for judging whether a third video identifier exists in the first dictionary or not when a searching instruction for searching for a playing record corresponding to the third video identifier is received, wherein the third video identifier is carried by the searching instruction, or the third video identifier is obtained by inquiring from a second dictionary according to a second album identifier carried by the searching instruction; and if the third video identifier exists, acquiring the playing record corresponding to the third video identifier from the first dictionary.
The deleting unit is used for searching whether the fourth video identifier exists in the playlist or not when a deleting instruction for deleting the playing record corresponding to the fourth video identifier is received; when the fourth video identifier exists in the playlist, deleting the fourth video identifier from the playlist; searching whether a fourth video identifier exists in the first dictionary or not; when the fourth video identification exists in the first dictionary, deleting the fourth video identification and the playing record corresponding to the fourth video identification from the first dictionary; searching whether a fourth video identifier exists in the second dictionary or not; and when the fourth video identification exists in the second dictionary, deleting the fourth video identification and the album identification corresponding to the fourth video identification from the second dictionary.
In summary, an embodiment of the present invention provides a caching method and apparatus based on a play record, where the method includes: when a first play record carrying at least a first video identifier is received, whether a first album identifier exists in the first play record is searched. When the first album identifier does not exist, updating the play list and the first dictionary by using the content in the first play record; when the first album identification exists, whether a second video identification corresponding to the first album identification exists in the second dictionary is searched. When the second video identifier exists, deleting contents related to the second video identifier in the playlist, the first dictionary and the second dictionary, and updating the playlist, the first dictionary and the second dictionary according to the first playing record; and when the second video identifier does not exist, updating the playlist, the first dictionary and the second dictionary according to the first playing record. When a searching instruction for searching the third video identifier is received, the content related to the third video identifier can be searched from the first dictionary; when the deleted content corresponding to the fourth video identifier is deleted, the content corresponding to the fourth video identifier in the playlist, the first dictionary and the second dictionary is sequentially searched and deleted. By utilizing the playlist, the first dictionary and the second dictionary, when operations such as adding, deleting and searching the playing records are realized, required data can be quickly positioned, the operations are simpler and quicker, the playing record processing efficiency is improved, the playing record processing time complexity is reduced, and the O (1) level is reached.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, the system or system embodiments are substantially similar to the method embodiments and therefore are described in a relatively simple manner, and reference may be made to some of the descriptions of the method embodiments for related points. The above-described system and system embodiments are only illustrative, wherein the units described as separate parts may or may not be physically separate, and the parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A buffering method based on play records, the method comprising:
when a first play record at least carrying a first video identifier is received, judging whether a first album identifier exists in the first play record;
if the first album identification does not exist, executing an updating step;
if the first album identification exists, judging whether a second video identification corresponding to the first album identification exists in a second dictionary, wherein the second dictionary is used for storing the video identification and the album identification which have a corresponding relation, and data are stored in the second dictionary by adopting a Hash algorithm;
if the second video identifier exists in the second dictionary, deleting contents related to the second video identifier from a playlist, a first dictionary and the second dictionary, wherein the playlist is used for storing the video identifier watched by a user and corresponding reporting time, the first dictionary is used for storing the video identifier and playing record with a corresponding relation, and the first dictionary stores data by adopting a hash algorithm;
storing the first album identification and the first video identification to the second dictionary, and performing the updating step;
if the second video identifier does not exist in the second dictionary, storing the first video identifier and the first album identifier to the second dictionary, and executing the updating step;
the updating step includes:
and updating the playlist according to the first video identifier, and updating the first dictionary according to the first video identifier and a first play record.
2. The method of claim 1, wherein said updating the playlist based on the first video identification comprises:
judging whether the first video identifier exists in the playlist or not;
if the first video identifier exists in the playlist, adjusting the storage position of the first video identifier in the playlist by using the reporting time of the first playing record;
and if the first video identifier does not exist in the play list, storing the first video identifier into the play list according to the reporting time of the first play record.
3. The method of claim 1, wherein updating the first dictionary based on the first video identifier and the first play record comprises:
judging whether the first video identifier exists in the first dictionary or not;
if the first video identifier exists in the first dictionary, replacing the first playing record with the playing record corresponding to the first video identifier in the first dictionary;
and if the first video identifier does not exist in the first dictionary, storing the first video identifier and the first play record to the first dictionary.
4. The method of claim 1, further comprising:
when a search instruction for searching for a play record corresponding to a third video identifier is received, judging whether the third video identifier exists in the first dictionary, wherein the third video identifier is carried by the search instruction, or the third video identifier is obtained by inquiring from the second dictionary according to a second album identifier carried by the search instruction;
and if the third video identifier exists, acquiring a play record corresponding to the third video identifier from the first dictionary.
5. The method of claim 1, further comprising:
when a deletion instruction for deleting a play record corresponding to a fourth video identifier is received, searching whether the fourth video identifier exists in the play list;
when the fourth video identifier exists in the playlist, deleting the fourth video identifier from the playlist;
searching whether the fourth video identification exists in the first dictionary or not;
when the fourth video identification exists in the first dictionary, deleting the fourth video identification and the playing record corresponding to the fourth video identification from the first dictionary;
searching whether the fourth video identification exists in the second dictionary or not;
and when the fourth video identification exists in the second dictionary, deleting the fourth video identification and the album identification corresponding to the fourth video identification from the second dictionary.
6. The method of claim 1, wherein the deleting content associated with the second video identification from the playlist, the first dictionary, and the second dictionary comprises:
and deleting the second video identifier from a playlist, deleting the second video identifier and a play record corresponding to the second video identifier from a first dictionary, and deleting the second video identifier and the first album identifier from the second dictionary.
7. A playback record-based caching apparatus, comprising:
the first judging unit is used for judging whether a first album identifier exists in a first play record or not when the first play record at least carrying a first video identifier is received; if the first album mark does not exist, executing an updating unit; if the first album mark exists, executing a second judgment unit;
the second judging unit is configured to judge whether a second dictionary has a second video identifier corresponding to the first album identifier, where the second dictionary is configured to store video identifiers and album identifiers having a corresponding relationship, and the second dictionary stores data by using a hash algorithm; if the second video identifier exists in the second dictionary, executing a processing unit; if the second video identifier does not exist in the second dictionary, executing a storage unit;
the processing unit is configured to delete content related to the second video identifier from a playlist, a first dictionary, and the second dictionary, where the playlist is configured to store video identifiers watched by a user and corresponding reporting times, and the first dictionary is configured to store video identifiers and play records having a correspondence relationship; storing the first album identifier and the first video identifier to the second dictionary, and executing the updating unit, wherein data are stored in the first dictionary by adopting a hash algorithm;
the storage unit is used for storing the first video identifier and the first album identifier to the second dictionary and executing the updating unit;
and the updating unit is used for updating the playlist according to the first video identifier and updating the first dictionary according to the first video identifier and the first playing record.
8. The apparatus of claim 7, wherein the updating unit comprises:
the first updating module is used for judging whether the first video identifier exists in the playlist or not; if the first video identifier exists in the playlist, adjusting the storage position of the first video identifier in the playlist by using the reporting time of the first playing record; and if the first video identifier does not exist in the play list, storing the first video identifier into the play list according to the reporting time of the first play record.
9. The apparatus of claim 7, wherein the updating unit comprises:
the second updating module is used for judging whether the first video identifier exists in the first dictionary or not; if the first video identifier exists in the first dictionary, replacing the first playing record with the playing record corresponding to the first video identifier in the first dictionary; and if the first video identifier does not exist in the first dictionary, storing the first video identifier and the first play record to the first dictionary.
10. The apparatus of claim 7, further comprising:
the searching unit is used for judging whether the third video identifier exists in the first dictionary or not when a searching instruction for searching for a playing record corresponding to the third video identifier is received, wherein the third video identifier is carried by the searching instruction, or the third video identifier is obtained by inquiring from the second dictionary according to a second album identifier carried by the searching instruction; and if the third video identifier exists, acquiring a play record corresponding to the third video identifier from the first dictionary.
CN202210029420.7A 2022-01-12 2022-01-12 Caching method and device based on play records Active CN114051162B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210029420.7A CN114051162B (en) 2022-01-12 2022-01-12 Caching method and device based on play records

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210029420.7A CN114051162B (en) 2022-01-12 2022-01-12 Caching method and device based on play records

Publications (2)

Publication Number Publication Date
CN114051162A CN114051162A (en) 2022-02-15
CN114051162B true CN114051162B (en) 2022-04-26

Family

ID=80196243

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210029420.7A Active CN114051162B (en) 2022-01-12 2022-01-12 Caching method and device based on play records

Country Status (1)

Country Link
CN (1) CN114051162B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114282048B (en) * 2022-03-07 2022-05-27 飞狐信息技术(天津)有限公司 Playing record warehousing method and device, storage medium and electronic equipment

Family Cites Families (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5127459B2 (en) * 2006-03-27 2013-01-23 株式会社Ptp Recording / reproducing apparatus, system, and server
CN101221801B (en) * 2008-01-22 2012-12-05 腾讯科技(深圳)有限公司 Player and playing method
EP2248048A1 (en) * 2008-01-25 2010-11-10 Nxp B.V. Method and apparatus for organizing media data in a database
WO2009120004A2 (en) * 2008-03-24 2009-10-01 Kang Min Soo Keyword-advertisement method using meta-information related to digital contents and system thereof
CN103731682B (en) * 2014-01-26 2017-09-22 飞狐信息技术(天津)有限公司 Method, equipment and the system of synchronous viewing record are kept between a variety of viewing equipment
CN104822090B (en) * 2014-04-25 2017-12-01 腾讯科技(北京)有限公司 The methods, devices and systems of video playback
CN105516786B (en) * 2015-12-03 2019-02-26 浪潮软件集团有限公司 Play recording device, system and method
CN107277621A (en) * 2017-06-06 2017-10-20 环球智达科技(北京)有限公司 A kind of statistical method based on broadcasting record
CN108848403A (en) * 2018-07-27 2018-11-20 北京优酷科技有限公司 Watch the methods of exhibiting and device of record
CN110460905A (en) * 2019-09-03 2019-11-15 腾讯科技(深圳)有限公司 The automatic continuous playing method of video, device and storage medium based on more equipment
CN112667847A (en) * 2019-10-16 2021-04-16 北京奇艺世纪科技有限公司 Data caching method, data caching device and electronic equipment
CN112714359B (en) * 2019-10-24 2022-09-09 北京达佳互联信息技术有限公司 Video recommendation method and device, computer equipment and storage medium
CN113111214A (en) * 2021-04-22 2021-07-13 海信视像科技股份有限公司 Display method and display equipment for playing records
CN113139081B (en) * 2021-04-27 2023-10-27 中山亿联智能科技有限公司 Method for reporting online playing information of reading user with high efficiency and low delay
CN113518247B (en) * 2021-05-27 2023-06-02 北京奇艺世纪科技有限公司 Video playing method, related equipment and computer readable storage medium
CN113407770A (en) * 2021-06-24 2021-09-17 深圳智多豚物联技术有限公司 Cloud playback index service method and system based on redis
CN113727145B (en) * 2021-11-04 2022-03-01 飞狐信息技术(天津)有限公司 Video distribution method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN114051162A (en) 2022-02-15

Similar Documents

Publication Publication Date Title
US8826320B1 (en) System and method for voting on popular video intervals
US8713618B1 (en) Segmenting video based on timestamps in comments
US9792340B2 (en) Identifying data items
US11599591B2 (en) System and method for updating a search index
US20150186388A1 (en) Subtitle processing method, device and system and storage medium
CN104869439A (en) Video push method and device
US11210211B2 (en) Key data store garbage collection and multipart object management
JP2007012013A (en) Video data management device and method, and program
US9418154B2 (en) Push-model based index updating
CN114051162B (en) Caching method and device based on play records
US9594784B2 (en) Push-model based index deletion
CN110515895B (en) Method and system for carrying out associated storage on data files in big data storage system
CN112148920B (en) Data management method
CN102819570B (en) A kind of data access method, Apparatus and system
WO2023246259A1 (en) Video identification method and apparatus, computer device, and storage medium
CN107004036B (en) Method and system for searching logs containing a large number of entries
CN109359087B (en) Instant file indexing and searching method, device and system
US20060288033A1 (en) System for pre-caching reports of streaming data
CN111143582B (en) Multimedia resource recommendation method and device for updating association words in double indexes in real time
CN112836087A (en) Video attribute information acquisition method and device
US11860678B2 (en) Optimized sampling of resource content data for session recording under communication constraints by independently capturing agents
CN110929002B (en) Similar article duplicate removal method, device, terminal and computer readable storage medium
CN110650196B (en) Business processing system, method, electronic device and storage medium
CN112860630A (en) Real-time transformation data storage method and device, electronic equipment and storage medium
CN114385637A (en) Message processing method and device, electronic equipment and storage medium

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