{"id":13,"date":"2016-04-24T18:32:00","date_gmt":"2016-04-24T18:32:00","guid":{"rendered":"http:\/\/learnitworld.com\/?p=13"},"modified":"2023-02-20T13:32:04","modified_gmt":"2023-02-20T08:02:04","slug":"redis-short-description-and-steps-to-setup-on-linux-system","status":"publish","type":"post","link":"https:\/\/learnitworld.com\/index.php\/2016\/04\/24\/redis-short-description-and-steps-to-setup-on-linux-system\/","title":{"rendered":"Redis short Description and steps to setup on linux system"},"content":{"rendered":"\n<p>Redis is a \u201cNoSQL\u201d key-value data store, it is moreover called as a data structure server. Redis more over work as Memcached, but with Built-in persistence ( to disk) and more data-types.<\/p>\n\n\n\n<p>Persistence to disk means you can use Redis as a real database, rather than having just data in a volatile cache. data will not be lost when you restart, like with Memcached.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Other than persistence more data types also make it for<\/p>\n\n\n\n<p><strong>Data Types<\/strong><\/p>\n\n\n\n<ul><li>Strings<\/li><li>Hashes<\/li><li>lists<\/li><li>sets<\/li><li>sorted sets<\/li><li>bitmaps<\/li><li>hyperloglogs<\/li><\/ul>\n\n\n\n<p>And Redis provides atomic operations on above data types like:<\/p>\n\n\n\n<ul><li>Appending to a string<\/li><li>incrementing the value in a hash<\/li><li>pushing an element to a list<\/li><li>computing set intersection<\/li><li>union<\/li><li>difference<\/li><li>get the member with the highest rank in sorted set<\/li><\/ul>\n\n\n\n<p><strong>Commands<\/strong><\/p>\n\n\n\n<ul><li><strong>monitor<\/strong>&nbsp;&#8211; Watch current live commands. Use this with care on production<\/li><li><strong>keys&nbsp;<\/strong>&#8211; keys pattern (Reg expression) which is used to search keys.<\/li><li><strong>del<\/strong>&nbsp;&#8211; Delete keys.<\/li><li><strong>expire<\/strong>&nbsp;&#8211; set the expiration time of a key (eg. expire keyname 30 ).<\/li><li><strong>exists<\/strong>&nbsp;&#8211; Checks it a key exists<\/li><li><strong>get<\/strong>&nbsp;&#8211; get the key value<\/li><li><strong>set<\/strong>&nbsp;&#8211; add and update key value<\/li><li><strong>setnx<\/strong>&nbsp;&#8211; set the key only if key exists<\/li><li><strong>mget<\/strong>&nbsp;&#8211; batch command of get (like mget &lt;key&gt; &lt;key&gt; &#8230;)<\/li><li><strong>mset<\/strong>&nbsp;&#8211; batch command of set ( like mset &lt;key&gt; &lt;value&gt; &lt;key&gt; &lt;value&gt; &#8230;.)<\/li><\/ul>\n\n\n\n<p>Note there are many more commands which are like lrange,lindex,llen.. for more command please refer to&nbsp;<a href=\"https:\/\/www.blogger.com\/blog\/post\/edit\/8273289315854531511\/918001230598100327#\">Redis Commands<\/a>.<\/p>\n\n\n\n<p><strong>Installation<\/strong><\/p>\n\n\n\n<p><em><strong>For Ubuntu:<\/strong><\/em><\/p>\n\n\n\n<p>To install redis server and to configure it with PHP run below command<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>sudo apt-get install redis-server;<\/p><p>sudo apt-get install php5-redis;<\/p><p>## redis configuration file<\/p><p>sudo vi \/etc\/redis\/redis.conf<\/p><\/blockquote>\n\n\n\n<p>Steps to configure Php to handle session using Redis<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>sudo vi \/etc\/php5\/apache2\/php.ini<br>## Find session.save_handler and change it&#8217;s value to redis<br>session.save_handler = redis<br>## Find session.save_path and change it&#8217;s value to IP:6379 (default port)<\/p><p>## after these changes run<br>sudo \/etc\/init.d\/redis-server restart<br>sudo \/etc\/init.d\/apache2 restart\/reload<\/p><\/blockquote>\n\n\n\n<p><em><strong>For Centos 6.5<\/strong><\/em><\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>wget http:\/\/dl.fedoraproject.org\/pub\/epel\/6\/x86_64\/epel-release-6-8.noarch.rpm<br>wget http:\/\/rpms.famillecollet.com\/enterprise\/remi-release-6.rpm<br>rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm<br>yum install redis php-pecl-redis<br>service redis start<br>chkconfig redis on<\/p><p>sudo vi \/etc\/php.ini<br>## Find session.save_handler and change it&#8217;s value to redis<br>session.save_handler = redis<br>## Find session.save_path and change it&#8217;s value to IP:6379 (default port)<\/p><p>session.save_path = &#8220;127.0.0.1:6379&#8221;<\/p><p>## after these changes run<br>sudo \/etc\/init.d\/redis restart<br>sudo \/etc\/init.d\/httpd restart\/reload<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Redis is a \u201cNoSQL\u201d key-value data store, it is moreover called as a data structure server. Redis more over work as Memcached, but with Built-in persistence ( to disk) and more data-types. Persistence to disk means you can use Redis as a real database, rather than having just data in a volatile cache. data will not be lost when you [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":36,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/learnitworld.com\/index.php\/wp-json\/wp\/v2\/posts\/13"}],"collection":[{"href":"https:\/\/learnitworld.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learnitworld.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learnitworld.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learnitworld.com\/index.php\/wp-json\/wp\/v2\/comments?post=13"}],"version-history":[{"count":1,"href":"https:\/\/learnitworld.com\/index.php\/wp-json\/wp\/v2\/posts\/13\/revisions"}],"predecessor-version":[{"id":14,"href":"https:\/\/learnitworld.com\/index.php\/wp-json\/wp\/v2\/posts\/13\/revisions\/14"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/learnitworld.com\/index.php\/wp-json\/wp\/v2\/media\/36"}],"wp:attachment":[{"href":"https:\/\/learnitworld.com\/index.php\/wp-json\/wp\/v2\/media?parent=13"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learnitworld.com\/index.php\/wp-json\/wp\/v2\/categories?post=13"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learnitworld.com\/index.php\/wp-json\/wp\/v2\/tags?post=13"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}