{"id":17644,"date":"2024-07-23T17:33:21","date_gmt":"2024-07-23T09:33:21","guid":{"rendered":"https:\/\/aiportek.com\/?page_id=17644"},"modified":"2024-07-24T09:53:01","modified_gmt":"2024-07-24T01:53:01","slug":"getting-started","status":"publish","type":"page","link":"https:\/\/aiportek.com\/en\/getting-started\/","title":{"rendered":"Getting Started with Redis"},"content":{"rendered":"<div data-elementor-type=\"wp-page\" data-elementor-id=\"17644\" class=\"elementor elementor-17644\" data-elementor-post-type=\"page\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-332f016d elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"332f016d\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-5b35ece7\" data-id=\"5b35ece7\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-ad77d0e elementor-widget elementor-widget-heading\" data-id=\"ad77d0e\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Getting Started with Redis<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d2788df elementor-widget elementor-widget-text-editor\" data-id=\"d2788df\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>This is an introductory guide to Redis. You will learn how to install, run, and test the Redis server process.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-64fd00a5 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"64fd00a5\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-3ea9dbaa\" data-id=\"3ea9dbaa\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-3796edcb elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"3796edcb\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-7219be37\" data-id=\"7219be37\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-e345f91 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"e345f91\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-7f967257\" data-id=\"7f967257\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-2b762c21 elementor-widget elementor-widget-text-editor\" data-id=\"2b762c21\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><strong>Installing Redis<\/strong><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-5ac28e66 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"5ac28e66\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-4eb1ba94\" data-id=\"4eb1ba94\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-7bfdd92d elementor-widget elementor-widget-text-editor\" data-id=\"7bfdd92d\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><span style=\"color: #333333;\">How you install Redis depends on your operating system. See below for the guide that best suits your needs:<\/span><\/p><p>\u00a0<\/p><ul><li><span style=\"color: #3366ff;\"><a style=\"color: #3366ff;\" href=\"https:\/\/redis.io\/docs\/latest\/operate\/oss_and_stack\/install\/\">Installing Redis from Source<\/a><\/span><\/li><li><span style=\"color: #3366ff;\"><a style=\"color: #3366ff;\" href=\"https:\/\/redis.io\/docs\/latest\/operate\/oss_and_stack\/install\/install-redis\/install-redis-on-linux\/\">Installing Redis on Linux<\/a><\/span><\/li><li><span style=\"color: #3366ff;\"><a style=\"color: #3366ff;\" href=\"https:\/\/redis.io\/docs\/latest\/operate\/oss_and_stack\/install\/install-redis\/install-redis-on-mac-os\/\">Installing Redis on macOS<\/a><\/span><\/li><li><span style=\"color: #3366ff;\"><a style=\"color: #3366ff;\" href=\"https:\/\/redis.io\/docs\/latest\/operate\/oss_and_stack\/install\/install-redis\/install-redis-on-windows\/\">Installing Redis on Windows<\/a><\/span><\/li><\/ul><p><span style=\"color: #333333;\">Once you have Redis up and running and can connect using redis-cli, you can continue with the following steps.<\/span><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-60a09cef elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"60a09cef\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-7a533788\" data-id=\"7a533788\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-4fa3f443 elementor-widget elementor-widget-text-editor\" data-id=\"4fa3f443\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><strong>Exploring Redis with the CLI<\/strong><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-41f1cc78 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"41f1cc78\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-1905158\" data-id=\"1905158\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-75b8ca31 elementor-widget elementor-widget-text-editor\" data-id=\"75b8ca31\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><span style=\"color: #333333;\">External programs talk to Redis using the TCP interface and a Redis-specific protocol. This protocol is available in the Redis client for different programming languages. To make Redis even simpler, Redis provides a useful command-line program for sending commands to Redis. This program is called redis-cli.<\/span><\/p><p>\u00a0<\/p><p><span style=\"color: #333333;\">To check if Redis is working properly, first send the PING command using redis-cli:<\/span><\/p><p>\u00a0<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-907d489 elementor-widget elementor-widget-text-editor\" data-id=\"907d489\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><span style=\"font-family: Terminal, Monaco;\">$ redis-cli ping<\/span><\/p><p><span style=\"font-family: Terminal, Monaco;\">PONG<\/span><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-24ad2330 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"24ad2330\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-2a5d44a8\" data-id=\"2a5d44a8\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-8a9bfab elementor-widget elementor-widget-text-editor\" data-id=\"8a9bfab\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><span style=\"color: #333333;\">After running redis-cli, this command is sent to the redis instance running on the host (port 6379) based on the command name and its parameters. You can change the host and port used by redis-cli, just try the -help option to check the usage information.<\/span><\/p><p>\u00a0<\/p><p><span style=\"color: #333333;\">Another interesting way to run redis-cli is without parameters: the program will start in interactive mode. You can type different commands and see the replies.<\/span><\/p><p>\u00a0<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-3944212 elementor-widget elementor-widget-text-editor\" data-id=\"3944212\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><span style=\"font-family: Terminal, Monaco;\">$ redis-cli<\/span><\/p><p><span style=\"font-family: Terminal, Monaco;\">redis 127.0.0.1:6379&gt; ping<\/span><\/p><p><span style=\"font-family: Terminal, Monaco;\">PONG<\/span><\/p><p><span style=\"font-family: Terminal, Monaco;\">redis 127.0.0.1:6379&gt; set mykey somevalue<\/span><\/p><p><span style=\"font-family: Terminal, Monaco;\">OK<\/span><\/p><p><span style=\"font-family: Terminal, Monaco;\">redis 127.0.0.1:6379&gt; get mykey<\/span><\/p><p><span style=\"font-family: Terminal, Monaco;\">\"somevalue\"<\/span><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-c2f30ea elementor-widget elementor-widget-text-editor\" data-id=\"c2f30ea\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><span style=\"color: #000000;\"><span style=\"color: #333333;\">At this point, you can talk to Redis. You can pause this tutorial to start<\/span><span style=\"color: #3366ff;\"><a style=\"color: #3366ff;\" href=\"https:\/\/redis.io\/docs\/latest\/\">A 15-minute introduction to Redis data types<\/a><\/span>(math.) genus<span style=\"color: #333333;\">in order to learn some Redis commands.<\/span><\/span><\/p><p>\u00a0<\/p><p><span style=\"color: #333333;\">If you already know some basic Redis commands, you can continue.<\/span><\/p><p>\u00a0<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-164e916 elementor-widget elementor-widget-text-editor\" data-id=\"164e916\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><strong>Protecting Redis<\/strong><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-29b59fd5 elementor-widget elementor-widget-text-editor\" data-id=\"29b59fd5\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><span style=\"color: #333333;\">By default, Redis is bound to all interfaces and requires no authentication. This is great if you are using Redis in a very controlled environment, isolated from external networks and attacks. However, if an unhardened Redis is exposed to the network, there is a significant security risk. If you can't 100% determine whether your environment is secure, check the following steps to make Redis more secure, which are listed in order of increasing security.<\/span><\/p><p>\u00a0<\/p><p><span style=\"color: #333333;\">1) Ensure that the port used by Redis to listen for connections (6379 by default, 16379 if running Redis in cluster mode, and 26379 for Sentinel) has a firewall installed to ensure that no connections can be made to Redis from an external environment.<\/span><\/p><p><span style=\"color: #333333;\">2) Use a configuration file with the bind directive set to ensure that Redis responds only to the network interface you are using. For example, if you are only accessing Redis locally from the same computer, use only the loopback interface (127.0.0.1), and so on.<\/span><\/p><p><span style=\"color: #333333;\">3) Use the requirepass option to add an additional layer of security in case the client needs to authenticate using the AUTH command.<\/span><\/p><p><span style=\"color: #333333;\">4) If your environment requires encryption, use spiped or other SSL tunneling software to encrypt the communication between the Redis server and the Redis client.<\/span><\/p><p>\u00a0<\/p><p><span style=\"color: #333333;\">Note that a Redis instance exposed to the Internet without any security can be easily exploited, so make sure you are aware of this and apply at least one layer of firewall. Once the firewall is in place, try connecting with redis-cli from an external host to prove to yourself that you cannot access the instance.<\/span><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-113a34b0 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"113a34b0\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-49e23459\" data-id=\"49e23459\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-b980d60 elementor-widget elementor-widget-text-editor\" data-id=\"b980d60\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><strong>Using Redis in your application<\/strong><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-245a8dd6 elementor-widget elementor-widget-text-editor\" data-id=\"245a8dd6\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><span style=\"color: #333333;\">It is not enough to use Redis from the command line interface, the goal is to use it in your application. To do this, you need to download and install a Redis client library for your programming language. You can download and install a Redis client library for your programming language in the<\/span><span style=\"color: #000000;\"><span style=\"color: #3366ff;\"><a style=\"color: #3366ff;\" href=\"https:\/\/redis.io\/docs\/latest\/develop\/connect\/clients\/\">This page<\/a><\/span><\/span><span style=\"color: #333333;\">Find a complete list of clients in different languages on the<\/span><\/p><p>\u00a0<\/p><p><span style=\"color: #333333;\">For example, if you happen to use the Ruby programming language, our best advice is to use the<\/span><span style=\"color: #3366ff;\"><a style=\"color: #3366ff;\" href=\"https:\/\/github.com\/redis\/redis-rb\">Redis-rb<\/a><\/span><span style=\"color: #333333;\">Client. You can install it using the gem install redis command.<\/span><\/p><p><span style=\"color: #333333;\">These instructions are for Ruby, but in fact many of the mainstream language clients look very similar. If you want to create a Redis object and run the call method commands, see the following short interactive example in Ruby.<\/span><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9051afd elementor-widget elementor-widget-text-editor\" data-id=\"9051afd\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><span style=\"font-family: Terminal, Monaco;\">&gt;&gt; require 'rubygems'<\/span><\/p><p><span style=\"font-family: Terminal, Monaco;\">=&gt; false<\/span><\/p><p><span style=\"font-family: Terminal, Monaco;\">&gt;&gt; require 'redis'<\/span><\/p><p><span style=\"font-family: Terminal, Monaco;\">=&gt; true<\/span><\/p><p><span style=\"font-family: Terminal, Monaco;\">&gt;&gt; r = Redis.new<\/span><\/p><p><span style=\"font-family: Terminal, Monaco;\">=&gt; #<\/span><\/p><p><span style=\"font-family: Terminal, Monaco;\">&gt;&gt; r.ping<\/span><\/p><p><span style=\"font-family: Terminal, Monaco;\">=&gt; \"PONG\"<\/span><\/p><p><span style=\"font-family: Terminal, Monaco;\">&gt;&gt; r.set('foo','bar')<\/span><\/p><p><span style=\"font-family: Terminal, Monaco;\">=&gt; \"OK\"<\/span><\/p><p><span style=\"font-family: Terminal, Monaco;\">&gt;&gt; r.get('foo')<\/span><\/p><p><span style=\"font-family: Terminal, Monaco;\">=&gt; \"bar\"<\/span><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>","protected":false},"excerpt":{"rendered":"<p>Redis\u5165\u9580 \u9019\u662fRedis\u7684\u5165\u9580\u6307\u5357\u3002\u60a8\u5c07\u5b78\u7fd2\u5982\u4f55\u5b89\u88dd\u3001\u904b\u884c\u548c\u6e2c\u8a66Redis\u670d\u52d9\u5668\u9032\u7a0b \u5b89\u88ddRedis \u5982 &#8230; <a title=\"Getting Started with Redis\" class=\"read-more\" href=\"https:\/\/aiportek.com\/en\/getting-started\/\" aria-label=\"Read more about Redis\u5165\u9580\">Read more<\/a><\/p>","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"elementor_canvas","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"class_list":["post-17644","page","type-page","status-publish"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/aiportek.com\/en\/wp-json\/wp\/v2\/pages\/17644","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aiportek.com\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/aiportek.com\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/aiportek.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aiportek.com\/en\/wp-json\/wp\/v2\/comments?post=17644"}],"version-history":[{"count":22,"href":"https:\/\/aiportek.com\/en\/wp-json\/wp\/v2\/pages\/17644\/revisions"}],"predecessor-version":[{"id":17729,"href":"https:\/\/aiportek.com\/en\/wp-json\/wp\/v2\/pages\/17644\/revisions\/17729"}],"wp:attachment":[{"href":"https:\/\/aiportek.com\/en\/wp-json\/wp\/v2\/media?parent=17644"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}