CN111752975A - Data loading method and device based on Redis, computer equipment and storage medium - Google Patents

Data loading method and device based on Redis, computer equipment and storage medium Download PDF

Info

Publication number
CN111752975A
CN111752975A CN202010468016.0A CN202010468016A CN111752975A CN 111752975 A CN111752975 A CN 111752975A CN 202010468016 A CN202010468016 A CN 202010468016A CN 111752975 A CN111752975 A CN 111752975A
Authority
CN
China
Prior art keywords
redis
data
cache data
target
storage node
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.)
Pending
Application number
CN202010468016.0A
Other languages
Chinese (zh)
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.)
Ping An Property and Casualty Insurance Company of China Ltd
Original Assignee
Ping An Property and Casualty Insurance Company of China 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 Ping An Property and Casualty Insurance Company of China Ltd filed Critical Ping An Property and Casualty Insurance Company of China Ltd
Priority to CN202010468016.0A priority Critical patent/CN111752975A/en
Publication of CN111752975A publication Critical patent/CN111752975A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/26Visual data mining; Browsing structured data

Abstract

The application belongs to the field of data processing and discloses a data loading method and device based on Redis, computer equipment and a readable storage medium. The method comprises the steps that when the operation that a user inputs Redis configuration information is detected, the Redis configuration information is communicated with a target Redis according to the configuration information input by the user; detecting whether the connection with the target Redis is successful; when the data are successfully communicated to the target Redis, generating a node traversal thread for each storage node in the target Redis, and traversing the storage node at regular time to obtain Redis cache data under the storage node; and storing the Redis cache data in a preset database and then sending the data to a front end for display. The method solves the technical problem that the efficiency of acquiring data on the Redis cluster is low in the prior art.

Description

Data loading method and device based on Redis, computer equipment and storage medium
Technical Field
The present application relates to the field of data processing, and in particular, to a data loading method and apparatus based on Redis, a computer device, and a storage medium.
Background
The Redis data management tool is a tool for managing data on a Redis cluster, so that a user can better view and operate Redis, manage and maintain mastered Redis cache data, and generally connect with a target Redis by acquiring configuration information of the user.
Disclosure of Invention
Based on this, it is necessary to solve the above technical problems, and the present application provides a data loading method and apparatus based on Redis, a computer device, and a storage medium, so as to solve the technical problem in the prior art that the efficiency of obtaining data on a Redis cluster is low.
A method of data loading based on Redis, the method comprising:
if the operation that a user inputs Redis configuration information is detected, communicating with a target Redis according to the configuration information input by the user;
detecting whether the connection with the target Redis is successful;
when the data are successfully communicated to the target Redis, generating a node traversal thread for each storage node in the target Redis, and traversing the storage node at regular time to obtain Redis cache data under the storage node; and are
And storing the Redis cache data into a preset database and then sending the data to a front end for display.
A Redis-based data loading apparatus, the apparatus comprising:
the communication connection module is used for communicating with a target Redis according to the configuration information input by the user if the operation of inputting the Redis configuration information by the user is detected;
the communication detection module is used for detecting whether the communication with the target Redis is successful or not;
the data cache module is used for generating a node traversal thread for each storage node in the target Redis when the data cache module is successfully communicated to the target Redis, and traversing the storage nodes at regular time to obtain Redis cache data under the storage nodes; and are
And the data display module is used for storing the Redis cache data into a preset database and then sending the data to the front end for display.
A computer device comprising a memory and a processor, and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the above-mentioned Redis-based data loading method when executing the computer program.
A computer readable storage medium, storing a computer program which, when executed by a processor, implements the steps of the above-described Redis-based data loading method.
According to the data loading method, device, computer equipment and storage medium based on Redis, the target Redis is automatically connected according to the configuration information input by the user, the traversal thread is built for each storage node on the target Redis after the communication is successful, a part of data can be loaded from the target Redis in advance and stored in a local preset database before the data is acquired by inputting the access command by the user, the speed of acquiring the user data is increased, and the pressure of a Redis cluster is reduced. And moreover, each storage node can be traversed at regular time, newly-added data under each storage node can be obtained in time and stored in a preset database, and the newly-added data are sent to a front-end page for rendering and displaying. The technical problem that the efficiency of acquiring data on the Redis cluster is low in the prior art is solved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without inventive labor.
FIG. 1 is a schematic diagram of an application environment of a Redis-based data loading method;
FIG. 2 is a flow diagram of a Redis-based data loading method;
FIG. 3 is a schematic flow chart of step 208 in FIG. 2;
FIG. 4 is a flowchart illustrating another embodiment of a Redis-based data loading method;
FIG. 5 is a schematic diagram of a Redis-based data loading device;
FIG. 6 is a diagram of a computer device in one embodiment.
Detailed Description
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used in the description of the application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "including" and "having," and any variations thereof, in the description and claims of this application and the description of the above figures are intended to cover non-exclusive inclusions. The terms "first," "second," and the like in the description and claims of this application or in the above-described drawings are used for distinguishing between different objects and not for describing a particular order.
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 application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application. 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.
The Redis-based data loading method provided by the embodiment of the invention can be applied to the application environment shown in FIG. 1. The application environment may include a terminal 102, a network for providing a communication link medium between the terminal 102 and the server 104, and a server 104, wherein the network may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may use the terminal 102 to interact with the server 104 over a network to receive or send messages, etc. The terminal 102 may have installed thereon various communication client applications, such as a web browser application, a shopping application, a search application, an instant messaging tool, a mailbox client, social platform software, and the like.
The terminal 102 may be various electronic devices having a display screen and supporting web browsing, including but not limited to a smart phone, a tablet computer, an e-book reader, an MP3 player (Moving Picture Experts Group audio Layer III, mpeg compression standard audio Layer 3), an MP4 player (Moving Picture Experts Group audio Layer IV, mpeg compression standard audio Layer 4), a laptop portable computer, a desktop computer, and the like.
The server 104 may be a server that provides various services, such as a background server that provides support for pages displayed on the terminal 102.
It should be noted that the data loading method based on Redis provided in the embodiment of the present application is generally executed by a server/terminal, and accordingly, the data loading apparatus based on Redis is generally disposed in a server/terminal device.
It should be understood that the number of terminals, networks and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Wherein, the terminal 102 communicates with the server 104 through the network. The server 104 detects the operation of Redis configuration information input by a user, communicates with a target Redis according to the configuration information, generates a node traversal thread for each storage node of the target Redis after the communication is successful, periodically traverses the storage nodes, loads Redis cache data on the storage nodes, stores the Redis cache data in preset data on the terminal 102, and displays the Redis cache data on a front-end page. The terminal 102 and the server 104 are connected through a network, the network may be a wired network or a wireless network, the terminal 102 may be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices, and the server 104 may be implemented by an independent server or a server cluster formed by a plurality of servers.
In an embodiment, as shown in fig. 2, a data loading method based on Redis is provided, which is described by taking the application of the method to a server in fig. 1 as an example, and includes the following steps:
step 202, detecting user operation, and if detecting that the user inputs Redis configuration information, communicating with the target Redis according to the configuration information.
In this embodiment, a server is taken as an example of a Redis management tool, the Redis tool is a configuration tool developed based on Java and capable of running in a Windows or Linux environment, a working interface of the reds tool is very concise, and a plurality of access commands for acquiring Redis data of different data types are encapsulated in the configuration tool. The Redis tool can enable a user to better view and operate Redis and manage and maintain the data cached by the mastered Redis. Wherein Redis is a Key-Value database.
The configuration information includes: target address of target redis, user name of user, password, initial connection pool length, maximum connection, whether to verify connection availability when acquiring connection, and so on. Wherein the target address includes a URL and a port (path and port) of the target Redis. And the user uses a class library of Jedis to connect the target Redis according to the target address, the user name and the user password of the target Redis to be accessed through the Redis tool, and the Redis tool and the target Redis realize network connection through tcp/ip communication. The embodiment calls the jedis class library to connect with the redis to solve the simple problem. Jedis is a Java connection development tool recommended by Redis officials, a Jedis object can be created when a target Redis is connected, and then a target address, a user name and a password are designated for the Jedis object, so that the purpose of communicating with the target Redis is achieved.
Specifically, a typical Redis tool will have a default configuration:
maxTotal: maximum number of connections of resource pool, default 8, suggest: setting (10) as required;
maxIdle: the resource pool allows the maximum number of idle connections, defaults to 8, suggesting: maxTotal;
minIdle: the resource pool ensures a minimum number of idle connections, defaults to 0, suggesting: preheating a mini;
jmxEnabled: whether jmx monitoring is turned on and available for monitoring, default true, and advise to turn on;
blockWhenExhausted is that the caller waits after the resource pool is exhausted. Only when true will maxWaitMillis validated, default true suggesting that default values are used;
MaxWaitMillis, when the resource pool connection is exhausted, the maximum waiting time (unit millisecond) of the caller is defaulted to-1: indicating a time-out is never exceeded;
testOnBorrow, which is to borrow connection from a resource pool and check whether connection validity (ping) is performed, invalid connection is removed, and default is that false suggests false;
testOnReturn, namely whether a connection validity test (ping) is carried out when returning the connection to the resource pool, invalid connection is removed, default false, and suggestion false;
one example of a suitable maxTotal is:
if the average execution time of the command is 0.001s, 50000QPS is required for the service, and the theoretical value of maxTotal is 0.001 × 50000 is 50, and the actual value is slightly larger. nodes (e.g., number of applications) × maxTotal cannot exceed the maximum number of connections of the redis tool (the maximum number of client connections that the maxclusits redis tool can receive).
And step 204, detecting whether the communication with the target Redis is successful.
And when the communication is carried out, the user name and the password filled by the user are used for accessing the target address, and whether the interface corresponding to the target address can be communicated or not is checked. If the connection is not up, abnormal information is displayed on the Redis tool. The exception information includes the type of exception, such as: connection timeout, connection rejection, etc., prompting the user to perform reconnection operation according to the abnormal information. This exception information is returned to the Redis tool in the form of a string, such as:
java.net.SocketTimeoutException
server response timeout
java.net.ConnectException:Connection refused:connect
Server request timeout
If the connection is made, the connected information is returned.
And step 206, when successfully communicated to the target Redis, generating a node traversal thread for each storage node in the target Redis, and traversing the storage nodes at regular time to obtain Redis cache data under the storage nodes.
Since Redis is deployed based on clusters, traversing the key values traverses all storage nodes, which is very slow and consumes a lot of resources of Redis clusters. When there are massive key values in the Redis cluster, the full traversal and rendering also causes slow data acquisition. Therefore, in the embodiment, when it is detected that the Redis tool is started and is also communicated to the target Redis, the Redis tool automatically generates a node traversal thread traversal node for each storage node to obtain the Redis cache data, and the efficiency of loading the Redis cache data by a user through the Redis tool is improved in a mode of loading part of cache data in advance through multiple threads.
Furthermore, a traversal thread is generated for each storage node, all the storage nodes are periodically traversed through the traversal thread to obtain new cache data which may be added to each storage node, and the real-time performance of data acquisition is also guaranteed.
Acquiring the generation time of the offset of Redis cache data in a storage node; obtaining Redis cache data from the latest generation time. Specifically, Redis cache data under the storage node is loaded according to the generation time of an offset through the traversal thread timing, wherein the offset is a storage number of the Redis cache data on the storage node. Each piece of data under the storage node has a unique corresponding offset for identifying different data, when Redis cache data is acquired, the offset generation time of the Redis data can be acquired, and the Redis data is acquired from the latest generation time so as to ensure that the data displayed on the front end is the latest updated data; optionally, the data may be obtained from the new data number to the old data number in order from large to small, the number may be an offset, and it may be ensured that the data buffered on the front end is the latest updated data, where the new data has a change larger than the old data number.
Alternatively, the data on the storage nodes may be acquired in order from small to large as required.
Further, the first traversal obtains all data under the storage node, and the storage node is traversed from the beginning in the next traversal, because the key values on the storage node are all life-cycle-existent, Redis can assign a lifetime (seconds/milliseconds) to the key, and Redis automatically deletes the key after the lifetime elapses. In order to ensure that the retrieved data are all up-to-date, new Redis cache data need to be obtained by re-traversal and updated into the local preset database, so that inconsistency between the data in the local preset database and the storage node is prevented.
And step 208, storing the Redis cache data in a preset database and then sending the data to a front end for display.
And establishing a preset database locally to store the obtained Redis cache data, and then sending the Redis cache data to a front-end page for rendering and displaying. If the data is changed during the cache, the cache can be refreshed by refreshing the front-end page, or the cache can be deleted to obtain the data again to refresh the cache. And rendering and displaying the data type after the change at the front end.
Further, the data cached in the preset database does not exceed 10W, and the running efficiency of the Redis tool is guaranteed. The obtained data is cached in a preset database, when the Redis tool receives the operation of clicking the access command by a user, the search can go to the storage node to obtain the search, if the obtaining is wrong or overtime, the Redis tool can respectively obtain the cached data corresponding to the access command from the local preset database and render and display the cached data on the front end, so that the pressure of a server caused by repeated access to the target Redis under the conditions of access errors and the like can be reduced, and the data retrieval efficiency is improved. The reason for the default value of 10W is that the default database memory is limited, so as to prevent the tool from occupying too much memory and affecting other uses of the tool.
According to the data loading method based on Redis, the target Redis is automatically connected according to the configuration information input by the user, a traversal thread is built for each storage node on the target Redis after the communication is successful, a part of data can be loaded from the target Redis in advance and stored in a local preset database before the data is acquired by inputting an access command by the user, so that the speed of acquiring the user data is increased, and the pressure of a Redis cluster is reduced. And moreover, each storage node can be traversed at regular time, newly-added data under each storage node can be obtained in time and stored in a preset database, and the newly-added data are sent to a front-end page for rendering and displaying.
In one embodiment, as shown in FIG. 3, step 208, comprises:
step 302, monitoring data change information of Redis cache data in a preset database, wherein the data change information includes an offset of the Redis cache data.
The Redis cache data is pre-loaded into a local preset database to facilitate the query of a user, and the pre-loaded partial data on the Redis can ensure that a subsequent user can also retrieve and analyze the data in the local data, so that the pressure of a server is reduced.
And step 304, if the data change information is that the offset of the Redis cache data in the preset database is sequentially increased, refreshing the front-end page to display the Redis cache data after the data information is changed.
The Redis cache data in the local preset database is rendered and then visually displayed on a front-end page, and the digitized information is displayed in a graphical mode, so that the user information absorption efficiency is improved.
The data change information may be that the size of the Redis cache data is changed, for example, a part of the Redis cache data is added, where the Redis cache data is added in the order of the offset from new to old. The embodiment can refresh the front-end page by acquiring the data change information of the Redis cache data in the preset database, so that new data can be displayed on the front-end page in time.
Optionally, it may also occur that data is updated due to a data storage period on the Redis cluster, so that data in the preset database is changed, and the detected data change information may be: the offset is inconsistent with the offset of the Redis cache data in the original preset database from a smaller number, so that the data in the preset database needs to be deleted and reloaded. Namely, it is
And step 306, if the data change information indicates that the offset of the Redis cache data in the preset database is increased in a jumping manner, deleting the Redis cache data in the preset database, repeatedly acquiring the Redis cache data from the target Redis, storing the Redis cache data in the preset database, and sending the Redis cache data to the front-end page rendering and displaying operation.
Optionally, whether to delete the data in the preset database for retrieval may be determined by comparing the local data with the data on the storage node at regular time.
Optionally, the data in the preset database may be deleted at regular time according to the life cycle of the data on the Redis cluster to be reacquired to ensure that the data in the local preset database is consistent with the data on the storage node, so as to avoid a situation that the data obtained by the user during the data search is inconsistent with the data on the Redis due to the life cycle of the data on the Redis.
The Redis cache data displayed on the front end according to the data change information in the preset database is updated, so that the user can search the required data in time, and the data processing efficiency is improved.
In an embodiment, as shown in fig. 4, the method for loading data based on Redis further includes:
after the data are communicated to the target Redis and the node traversal thread is generated for each storage node in the target Redis to traverse the storage node at regular time to obtain Redis cache data under the storage node, when the operation that a user sends a data fetching command is detected, the Redis cache data of the data type corresponding to the data fetching command are obtained from the target Redis and stored in a preset database and then displayed at the front end.
If the user inputs an access command to acquire data, Redis cache data of a data type corresponding to the access command can be acquired from the target Redis and rendered and displayed on a front-end page.
Specifically, obtaining Redis cache data of a data type corresponding to the access command from the target Redis, storing the Redis cache data in a preset database, and displaying the Redis cache data at the front end, wherein the method comprises the following steps:
step 402, searching Redis cache data corresponding to a preset access command on a storage node corresponding to a target storage node;
step 404, storing the acquired Redis cache data to a preset database, and displaying the data on a front-end page.
And step 406, if the search on the storage node corresponding to the target storage node fails, acquiring Redis cache data corresponding to the preset access command from a preset database, and displaying the Redis cache data on a front-end page.
Optionally, obtaining the Redis cache data of the data type corresponding to the access command from the preset database and then displaying the Redis cache data at the front end, where the display includes:
if the access command is received, acquiring Redis cache data corresponding to the access command from a preset database, and displaying the Redis cache data at the front end;
and if the search in the preset database fails, acquiring Redis cache data corresponding to the access command from the target Redis, and displaying the Redis cache data on the front end.
In the embodiment, the data corresponding to the data fetching command is acquired from the Redis cache data pre-loaded in the preset data, the required data can be acquired from the specific storage node on the target Redis, the probability that the data can be successfully acquired is ensured from two aspects, the user can be ensured to retrieve and analyze the data in the local data, and the pressure of the server is reduced.
It should be understood that although the various steps in the flowcharts of fig. 2-4 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 2-4 may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performing the sub-steps or stages is not necessarily sequential, but may be performed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.
In one embodiment, as shown in fig. 5, a data loading apparatus based on Redis is provided, where the data loading apparatus based on Redis corresponds to the data loading method based on Redis in the foregoing embodiment one to one. The data loading device based on Redis comprises:
the communication connection module 502 is configured to, when an operation of inputting the Redis configuration information by a user is detected, communicate with the target Redis according to the configuration information input by the user;
a communication detection module 504, configured to detect whether communication with the target Redis is successful;
the data cache module 506 is configured to generate a node traversal thread for each storage node in the target Redis to traverse the storage node at regular time when the storage node is successfully communicated to the target Redis, so as to obtain Redis cache data under the storage node; and
and the data display module 508 is configured to store the Redis cache data in a preset database and send the data to the front end for display.
Further, the communication connection module 502 includes:
the information acquisition submodule is used for acquiring a user name, a password and a target address of a target Redis from the Redis configuration information;
and the cluster communication submodule is used for calling Jedis to connect the target address, verifying the legality through the user name and the password and communicating the target Redis.
Further, the data caching module 506 includes:
the thread generation submodule is used for generating the traversal thread for each storage node;
and the data loading submodule is used for loading the Redis cache data under the storage node according to a data offset at regular time through the traversal thread, wherein the data offset is a storage number of the Redis cache data on the storage node. Further, after the data display module 508, the method further includes:
the data change acquisition submodule is used for monitoring data change information of Redis cache data in a preset database, wherein the data change information comprises offset of the Redis cache data;
the first data updating submodule is used for refreshing a front-end page to display the changed Redis cache data when the data change information is that the offset of the Redis cache data in the preset database is sequentially increased; or
And the second data updating submodule is used for deleting Redis cache data in the preset database if the data change information is that the offset of the Redis cache data in the preset database is increased in a jumping mode, repeatedly acquiring the Redis cache data from the target Redis, storing the Redis cache data in the preset database, and sending the Redis cache data to the front-end page rendering and displaying operation.
Further, the data loading device based on Redis further includes:
and the command loading module is used for acquiring Redis cache data of a data type corresponding to the access command from the target Redis when the operation that the user sends the access command is detected, storing the Redis cache data in a preset database and displaying the Redis cache data at the front end. Further, a command loading module comprising:
the node data acquisition submodule is used for searching Redis cache data corresponding to a preset access command on a storage node corresponding to a target storage node;
the data display sub-module is used for storing the acquired Redis cache data to a preset database and displaying the data on a front-end page;
and the local data acquisition submodule is used for acquiring Redis cache data corresponding to the preset access command from a preset database and displaying the Redis cache data on a front-end page if the search on the storage node corresponding to the target storage node fails.
According to the data loading device based on the Redis, the target Redis is automatically connected according to the configuration information input by the user, the traversal thread is built for each storage node on the target Redis after the communication is successful, a part of data can be loaded from the target Redis in advance and stored in a local preset database before the data is acquired by inputting the data acquisition command by the user, the speed of acquiring the user data is increased, and the pressure of a Redis cluster is reduced. And moreover, each storage node can be traversed at regular time, newly-added data under each storage node can be obtained in time and stored in a preset database, and the newly-added data are sent to a front-end page for rendering and displaying.
In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as shown in fig. 6. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is for storing Redis data. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a Redis-based data loading method.
As will be understood by those skilled in the art, the computer device is a device capable of automatically performing numerical calculation and/or information processing according to a preset or stored instruction, and the hardware includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and the computer program, when executed by a processor, implements the steps of the Redis-based data loading method in the above-described embodiment, for example, the steps 202 to 208 shown in fig. 2, or implements the functions of the modules/units of the Redis-based data loading apparatus in the above-described embodiment, for example, the functions of the modules 502 to 508 shown in fig. 5, when the processor executes the computer program. To avoid repetition, further description is omitted here. By automatically connecting the target Redis according to configuration information input by a user and constructing a traversal thread for each storage node on the target Redis to traverse the storage nodes at regular time after the communication is successful, a part of data can be loaded from the target Redis and stored in a local preset database before the user inputs an access command to acquire the data, so that the speed of acquiring the user data is increased, and the pressure of a Redis cluster is reduced. And moreover, each storage node can be traversed at regular time, newly-added data under each storage node can be obtained in time and stored in a preset database, and the newly-added data are sent to a front-end page for rendering and displaying.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for those skilled in the art, without departing from the spirit and scope of the present invention, several changes, modifications and equivalent substitutions of some technical features may be made, and these changes or substitutions do not make the essence of the same technical solution depart from the spirit and scope of the technical solution of the embodiments of the present invention. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A Redis-based data loading method, the method comprising:
if the operation that a user inputs Redis configuration information is detected, communicating with a target Redis according to the configuration information input by the user;
detecting whether the connection with the target Redis is successful;
when the data are successfully communicated to the target Redis, generating a node traversal thread for each storage node in the target Redis, and traversing the storage nodes at regular time to obtain Redis cache data under the storage nodes; and are
And storing the Redis cache data into a preset database and then sending the data to a front end for display.
2. The method according to claim 1, wherein the communicating with a target Redis according to the configuration information input by a user comprises:
acquiring a user name, a password and a target address of a target Redis from the Redis configuration information;
and calling Jedis to connect a target address, verifying the legality through the user name and the password, and communicating the target Redis.
3. The method according to claim 1, wherein the generating a node traversal thread for each storage node in the target Redis to traverse the storage node at a certain time to obtain Redis cache data under the storage node comprises:
generating the traversal thread for each storage node;
loading Redis cache data under the storage node according to a data offset at regular time through the traversal thread, wherein the data offset is a storage number of the Redis cache data on the storage node.
4. The method according to claim 3, wherein the loading Redis cache data under the storage node by the traverse thread timing according to a data offset comprises:
acquiring the generation time of the offset of Redis cache data in a storage node;
obtaining Redis cache data from the latest generation time.
5. The method according to claim 3, wherein after the storing the Redis cache data in a preset database and sending the data to a front-end display, the method further comprises:
monitoring data change information of Redis cache data in a preset database, wherein the data change information comprises offset of the Redis cache data;
if the data change information is that the offset of Redis cache data in a preset database is sequentially increased, refreshing a front-end page to display the Redis cache data after the data information is changed; or
And if the data change information indicates that the offset of the Redis cache data in the preset database is increased in a jumping mode, deleting the Redis cache data in the preset database, repeatedly acquiring the Redis cache data from the target Redis, storing the Redis cache data in the preset database, and sending the Redis cache data to the front-end page rendering display operation.
6. The method according to claim 1, after said generating a node traversal thread for each storage node in a target Redis to traverse said storage node at a fixed time when communicated to said target Redis, and obtaining Redis cache data under said storage node, further comprising:
and when the operation that a user sends an access command is detected, acquiring Redis cache data of a data type corresponding to the access command from the target Redis, storing the Redis cache data in the preset database, and displaying the Redis cache data at the front end.
7. The method according to claim 6, wherein the access command includes a target storage node and a preset access command, the method includes obtaining Redis cache data of a data type corresponding to the access command from the target Redis, storing the Redis cache data in the preset database, and displaying the Redis cache data at a front end, and the method includes:
searching Redis cache data corresponding to the preset data fetching command on a storage node corresponding to the target storage node; and are
Storing the acquired Redis cache data to the preset database, and displaying the Redis cache data on a front-end page;
and if the searching on the storage node corresponding to the target storage node fails, acquiring Redis cache data corresponding to the preset access command from the preset database, and displaying the Redis cache data on a front-end page.
8. A data loading apparatus based on Redis, comprising:
the communication connection module is used for communicating with a target Redis according to the configuration information input by the user if the operation of inputting the Redis configuration information by the user is detected;
the communication detection module is used for detecting whether the communication with the target Redis is successful or not;
the data cache module is used for generating a node traversal thread for each storage node in the target Redis when the data cache module is successfully communicated to the target Redis, and traversing the storage nodes at regular time to obtain Redis cache data under the storage nodes; and are
And the data display module is used for storing the Redis cache data into a preset database and then sending the data to the front end for display.
9. A computer device comprising a memory and a processor, the memory storing a computer program, wherein the processor implements the steps of the method of any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
CN202010468016.0A 2020-05-28 2020-05-28 Data loading method and device based on Redis, computer equipment and storage medium Pending CN111752975A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010468016.0A CN111752975A (en) 2020-05-28 2020-05-28 Data loading method and device based on Redis, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010468016.0A CN111752975A (en) 2020-05-28 2020-05-28 Data loading method and device based on Redis, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN111752975A true CN111752975A (en) 2020-10-09

Family

ID=72673851

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010468016.0A Pending CN111752975A (en) 2020-05-28 2020-05-28 Data loading method and device based on Redis, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111752975A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112540811A (en) * 2020-12-15 2021-03-23 平安科技(深圳)有限公司 Cache data detection method and device, computer equipment and storage medium
CN112948025A (en) * 2021-05-13 2021-06-11 阿里云计算有限公司 Data loading method and device, storage medium, computing equipment and computing system

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112540811A (en) * 2020-12-15 2021-03-23 平安科技(深圳)有限公司 Cache data detection method and device, computer equipment and storage medium
CN112948025A (en) * 2021-05-13 2021-06-11 阿里云计算有限公司 Data loading method and device, storage medium, computing equipment and computing system
CN112948025B (en) * 2021-05-13 2021-09-14 阿里云计算有限公司 Data loading method and device, storage medium, computing equipment and computing system

Similar Documents

Publication Publication Date Title
CN112910945A (en) Request link tracking method and service request processing method
CN103678549B (en) Webpage data sharing method and device
CN111708586B (en) Application starting configuration item loading method and device, computer equipment and storage medium
CN110309109B (en) Data monitoring method, device, computer equipment and storage medium
CN109586948A (en) Update method, apparatus, computer equipment and the storage medium of system configuration data
CN110489421B (en) Data storage method, apparatus, computer readable storage medium and computer device
CN108932332A (en) The loading method and device of static resource
CN110555041A (en) Data processing method, data processing device, computer equipment and storage medium
CN111752975A (en) Data loading method and device based on Redis, computer equipment and storage medium
CN106202082B (en) Method and device for assembling basic data cache
CN113347041B (en) Dynamic current-limiting fusing configuration method, device, equipment and storage medium
CN112612988A (en) Page processing method and device, computer equipment and storage medium
CN113094076A (en) Version iteration method, device, equipment and medium based on version control
CN109635217A (en) H5 page loading method, device, computer equipment and the storage medium of APP
CN109254804A (en) A kind of static resource loading method, device, equipment and readable storage medium storing program for executing
CN112035110A (en) Parameter adjusting method, device, client and storage medium
CN112926002A (en) Service request processing method and device
CN111177605B (en) Single-page loading performance monitoring method and device and related equipment
CN112069239A (en) Method, system, device and storage medium for using database based on HTTP request
CN110825603A (en) Page first loading time determining method and device, electronic equipment and storage medium
CN116302175A (en) Concurrent network request processing method, device, equipment and storage medium
CN115801541A (en) Slow access warning method and device in full-link tracking platform and computer equipment
CN114928620A (en) User information synchronization method, device, equipment, storage medium and program product
CN111258877B (en) Method and device for detecting visible time of first screen page and electronic equipment
CN110162542B (en) Data page turning method and device based on cassandra, computer 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