Cloud playback index service method and system based on redis

文档序号:7772 发布日期:2021-09-17 浏览:49次 中文

1. A cloud playback index service method based on redis is characterized by comprising the following steps:

s1, the data writing module receives the video information uploaded by the equipment and writes the data into the redis;

s2, the data merging module merges the data from the last merging time to the current time according to the rule at regular time, and updates the merged data to the redis;

s3, after the data query module receives a request of a video of the viewing device of the client in a certain time period, the data query module queries the record of the corresponding key in score in the redis in the time period, and then returns the record to the client.

2. The method of claim 1, wherein the data structure written in the redis in step S1 includes a start time of a first video of the recording, a duration of a single video, and a number of videos included in the recording.

3. The cloud playback index service method based on redis of claim 1, wherein the data in the redis written in step S1 with a video file name as the starting time of the video, and keys used when storing the redis are a character string consisting of "device ID + date of the day", and one key only stores data for one day.

4. The redis-based cloud playback index service method of claim 1, wherein the step S1 automatically deletes expired data due to expiration according to an expiration time set by a service.

5. The method for cloud playback index service based on redis according to claim 1, wherein when the record is stored in the ordered set in step S1, the start time of the first video file is recorded as score, and the time is used as an index condition when the query is facilitated.

6. The redis-based cloud playback index service method of claim 1, wherein the rules in step S2 are: when the duration of a single video of two records is equal and the starting time + the duration of the video + the number of videos of one record = the starting time of the other record, the two records are considered to be merged.

7. The redis-based cloud playback index service method of claim 1, wherein step S2 deletes two records before merging after data merging to avoid data duplication.

8. The redis-based cloud playback index service method of claim 1, wherein step S3 returns the recording extension as a video list to the client.

9. A redis-based cloud playback index service system, which is characterized by comprising a data writing module, a data merging module and a data query module as claimed in any one of claims 1-8; the data writing module is respectively in communication connection with the device and the redis, and is used for receiving video information transmitted from the device and writing data into the redis; the data merging module is in communication connection with the redis and is used for regularly merging the data from the last merging time to the current time according to rules and updating the merged data into the redis; the data query module is respectively in communication connection with the client and the redis, and is used for receiving a video request of the viewing device of the client in a certain time period, querying records of the corresponding key in the redis in the time period according to the request, expanding the records into a video list and returning the video list to the client.

Background

Currently, the prior art generally stores video file information through a database, and each video file corresponds to one record. With the rapid increase of the data volume, the data stored in the database is more and more huge, the space occupied by the database is very huge, the pressure caused by data query of a user is increased, the cost for using the database is increased while the access efficiency is greatly reduced, the access efficiency is low, and the service cost is high.

Accordingly, the prior art is deficient and needs improvement.

Disclosure of Invention

The invention aims to overcome the defects of the prior art and provides a cloud playback index service method and system based on redis.

The technical scheme of the invention is as follows:

firstly, the invention provides a cloud playback index service method based on redis, which comprises the following steps:

s1, the data writing module receives the video information uploaded by the equipment and writes the data into the redis;

s2, the data merging module merges the data from the last merging time to the current time according to the rule at regular time, and updates the merged data to the redis;

s3, after the data query module receives a request of a video of the viewing device of the client in a certain time period, the data query module queries the record of the corresponding key in score in the redis in the time period, and then returns the record to the client.

Further, the data structure written in redis in step S1 includes the start time of the first video of the record, the duration of the single video, and the number of videos contained in the record.

Further, the data in the redis written in step S1 is given that the video file name is the start time of the video, and the key used when storing the redis is a character string consisting of "device ID + date of the day", and one key stores only data for one day.

Further, step S1 automatically deletes expired data when the expiration time is set according to the service.

Further, when the record is stored in the ordered set in step S1, the start time of the first video file is recorded as score, which is convenient for query with time as an index condition.

Further, the rule in step S2 is: when the duration of a single video of two records is equal and the starting time + the duration of the video + the number of videos of one record = the starting time of the other record, the two records are considered to be merged.

Further, step S2 deletes the two records before merging after merging of the data to avoid duplication of the data.

Further, step S3 returns the record expanded to the video list to the client.

Secondly, the invention provides a cloud playback index service system based on redis, which comprises a data writing module, a data merging module and a data query module, wherein the data writing module, the data merging module and the data query module are used for writing data; the data writing module is respectively in communication connection with the device and the redis, and is used for receiving video information transmitted from the device and writing data into the redis; the data merging module is in communication connection with the redis and is used for regularly merging the data from the last merging time to the current time according to rules and updating the merged data into the redis; the data query module is respectively in communication connection with the client and the redis, and is used for receiving a video request of the viewing device of the client in a certain time period, querying records of the corresponding key in the redis in the time period according to the request, expanding the records into a video list and returning the video list to the client.

By adopting the scheme, the invention has the following beneficial effects:

according to the invention, through the redis storage file index, the video files in the corresponding time period of the equipment can be quickly and efficiently checked according to the time period by means of the high performance and the ordered set characteristic of the redis, the query efficiency is improved, the problem of low access efficiency after the data volume is large in the prior art is effectively solved, meanwhile, the continuous video information is combined into one record, the space required by the storage data is greatly reduced, the service cost is reduced, and the video files in the time period required to be checked by the equipment can be conveniently and quickly accessed.

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 some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the structures shown in the drawings without creative efforts.

FIG. 1 is a flowchart illustrating a cloud playback index service method based on redis according to the present invention;

FIG. 2 is a timing diagram of the operation of the data write module according to the present invention;

FIG. 3 is a business sequence diagram of the data merge module of the present invention;

FIG. 4 is a business sequence diagram of the data query module of the present invention.

The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.

Detailed Description

The invention is described in detail below with reference to the figures and the specific embodiments.

First, referring to fig. 1 to 4, the present invention provides a cloud playback index service method based on redis, including the following steps:

s1, the data writing module 1 receives the video information uploaded by the device 2 and writes the data into the redis3, at this time, the data are not merged and are directly written into the redis 3; the data structure written into the redis3 comprises the start time of the first video of the record, the time length of a single video and the number of videos contained in the record, the name of an appointed video file is the start time of the video, keys used when the video file is stored into the redis3 are character strings consisting of equipment ID and date of the day, one key only stores data of one day, the expired data is automatically deleted when the expired data is due according to the service setting, when the record is stored into an ordered set, the start time of the first video file is recorded as score, and the time is conveniently used as an index condition when the record is queried;

s2, the data merging module 4 merges the data from the last merging time to the current time according to the rule at regular time, and updates the merged data to the redis 3; the rule for the data merging module 4 to merge data is as follows: when the two records of single video have the same time length and the start time + video time length + video number of one record = the start time of the other record, the two records are considered to be merged, that is, the data merging module 4 periodically acquires all data from the last merging time to the current time, and merges all the two records satisfying "the two records of single video have the same time length and the start time + video time length + video number = the start time of the other record" in the acquired data; in order to avoid data duplication, after data is merged, the data merging module 4 deletes the two records before merging, so as to avoid data duplication;

s3, after the data query module 5 receives a request of a user for viewing videos in a certain time period on the device 2, records of the corresponding key in score in the redis3 in the time period are queried, and then the records are expanded into a video list and returned to the user, that is, the user sends a request for viewing videos in the certain time period on the device 2 to the data query module 5 through the client 6, after the data query module 5 receives the request for viewing videos in the certain time period on the device 2 from the client 6, the data query module 5 queries the records of the corresponding key in score in the redis3 in the time period, and then the records are expanded into the video list and returned to the client 6, and the user can view data listed in the video list through the client 6 at will.

Secondly, referring to fig. 2 to 4, the present invention further provides a cloud playback index service based on redis, including the data writing module 1, the data merging module 4, and the data querying module 5 described in the above method; the data writing module 1 is respectively connected with a device 2 and a redis3 in a communication manner, and the data writing module 1 is configured to receive video information transmitted from the device 2 and write corresponding data (i.e. the received video information and related data) into a redis 3; the data merging module 4 is communicatively connected to the redis3, where the data merging module 4 is configured to periodically acquire all data from the last merging time to the current time, merge all two records of the acquired data that satisfy "two records have the same video duration and one of the records starts with the video duration + the video number = the start of the other record", and update the merged data into the redis3 (i.e., write the merged data into the redis 3), that is, the data merging module 4 is configured to periodically merge the data from the last merging time to the current time according to rules, and update the merged data into the redis 3; the data query module 5 is respectively connected to the client 6 and the redis3 in a communication manner, and the data query module 5 is configured to accept a request sent by a user through the client 6 (the request is a request for viewing videos of the device 2 in a certain time period, but the request is not limited to viewing videos of the device 2 in a certain time period), query a record of score in a corresponding key in the redis3 in the time period according to the request, expand the record into a video list, and return the video list to the client 6 for the client to view, that is, the data query module 5 queries a record of score in a corresponding key in the redis3 in the time period according to a request for viewing videos of the device 2 in a certain time period of the client 6, and expands the record into a video list and returns the video list to the client 6.

Compared with the prior art, the invention has the following beneficial effects:

according to the invention, through the redis storage file index, the video files in the corresponding time period of the equipment can be quickly and efficiently checked according to the time period by means of the high performance and the ordered set characteristic of the redis, the query efficiency is improved, the problem of low access efficiency after the data volume is large in the prior art is effectively solved, meanwhile, the continuous video information is combined into one record, the space required by the storage data is greatly reduced, the service cost is reduced, and the video files in the time period required to be checked by the equipment can be conveniently and quickly accessed.

The present invention is not limited to the above preferred embodiments, and any modifications, equivalent substitutions and improvements made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

完整详细技术资料下载
上一篇:石墨接头机器人自动装卡簧、装栓机
下一篇:监控调度方法、系统、装置及存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!