Redis cluster configuration, Spring consolidated Jedis, cache synchronization

Source: Internet
Author: User
Tags connection pooling redis cluster

The front desk's product data (images and other slow loading) queries, first querying data from the Redis cache.

Redis is a NoSQL database, Memory Edition database, read Speed 11w/s. itself has a memory-elimination mechanism, is a single-threaded server (time-sharing operating system), thread safety.

Redis installation in Linux (standalone version): make;;

Modify for background start;

View process;

Virtual machine Simulation of Redis cluster construction:

Build steps:

Vim redis.conf,

Copy 7001, modify the other ports in turn;

Log in to the cluster:

To view node information:

The host is used for writing, from the machine as a backup;

The data deposited by the CRC algorithm specifies the hash slot, pointing to the disk space location;

To add a redis stand-alone to a cluster:

The added will be master;

Reallocate storage space:

./redis-trib.rb Reshard 192.168.74.132:7001 to reallocate 7001 of clusters (note)

Add from Node:

Then give 7008 space to allocate;

Redis clusters into the business:

Guide Package

Data stored in a Redis cluster is randomly assigned to one of the redis clusters;

Spring Integration Jedis:

1 <!--Redis Connection Pooling -2     <BeanID= "Poolconfig"class= "Redis.clients.jedis.JedisPoolConfig">3         < Propertyname= "Maxtotal"value= "$"></ Property>4         < Propertyname= "Maxidle"value= " the"></ Property>5     </Bean>6     <!--Create a Cluster object -7     <Beanclass= "Redis.clients.jedis.JedisCluster">8         <Constructor-argname= "Nodes">9             <Set>Ten                 <Beanclass= "Redis.clients.jedis.HostAndPort"> One                     <Constructor-argname= "Host"value= "192.168.66.66"></Constructor-arg> A                     <Constructor-argname= "Port"value= "7001"></Constructor-arg> -                 </Bean> -                  the                 <Beanclass= "Redis.clients.jedis.HostAndPort"> -                     <Constructor-argname= "Host"value= "192.168.66.66"></Constructor-arg> -                     <Constructor-argname= "Port"value= "7002"></Constructor-arg> -                 </Bean> +                  -                 <Beanclass= "Redis.clients.jedis.HostAndPort"> +                     <Constructor-argname= "Host"value= "192.168.66.66"></Constructor-arg> A                     <Constructor-argname= "Port"value= "7003"></Constructor-arg> at                 </Bean> -                  -                 <Beanclass= "Redis.clients.jedis.HostAndPort"> -                     <Constructor-argname= "Host"value= "192.168.66.66"></Constructor-arg> -                     <Constructor-argname= "Port"value= "7004"></Constructor-arg> -                 </Bean> in                  -                 <Beanclass= "Redis.clients.jedis.HostAndPort"> to                     <Constructor-argname= "Host"value= "192.168.66.66"></Constructor-arg> +                     <Constructor-argname= "Port"value= "7005"></Constructor-arg> -                 </Bean> the                  *                 <Beanclass= "Redis.clients.jedis.HostAndPort"> $                     <Constructor-argname= "Host"value= "192.168.66.66"></Constructor-arg>Panax Notoginseng                     <Constructor-argname= "Port"value= "7006"></Constructor-arg> -                 </Bean> the                  +                 <Beanclass= "Redis.clients.jedis.HostAndPort"> A                     <Constructor-argname= "Host"value= "192.168.66.66"></Constructor-arg> the                     <Constructor-argname= "Port"value= "7007"></Constructor-arg> +                 </Bean> -                  $                 <Beanclass= "Redis.clients.jedis.HostAndPort"> $                     <Constructor-argname= "Host"value= "192.168.66.66"></Constructor-arg> -                     <Constructor-argname= "Port"value= "7008"></Constructor-arg> -                 </Bean> the             </Set> -         </Constructor-arg>Wuyi         <Constructor-argname= "Poolconfig"ref= "Poolconfig"></Constructor-arg> the     </Bean>

The operation of caching by means of jediscluster;

After getting the data, add the cache:

Before getting the database data, get it from the cache:

1 Try {2String Adjson = Jedisdao.hget (Index_cache, categoryid+ "");3             if(Stringutils.isnotblank (Adjson)) {4list<aditem> adlist = jsonutils.jsontolist (Adjson, AdItem.class);5                 returnadlist;6             }7}Catch(Exception e) {8 e.printstacktrace ();9}

Cache synchronization:

Data add, modify, delete method set Clear cache:

Redis cluster configuration, Spring consolidated Jedis, cache synchronization

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.