zoukankan      html  css  js  c++  java
  • 【原】Spring整合Redis(第一篇)—SDR简述

    1、SDR说明
    Spring Data Redis(SDR),是SpringFramework提供的一套简化访问Redis的API,是对Jedis的又一层封装。
    SDR集成了Jedis,JRedis,SRP,Lettuce这四种开源的Redis Connector,这些Connector都是针对于Redis的开源Java库。其中,JRedis和SRP从spring-data-redis1.7开始,就不支持了。

    2、RedisTemplate说明
    RedisTemplate是SDR的一个核心Helper类,该类是一个高级的抽象(对Jedis的又一层封装),它封装了对Redis中的数据的CRUD操作,包含“高级封装”。
    (1)高级封装(推荐使用)
    高级封装的操作包含:OpsForValue(),OpsForList(),OpsForSet(),OpsForZset(),OpsForHash()等等。
    SDR官方文档中对Redistemplate的介绍:the template is in fact the central class of the Redis module due to its rich feature set. The template offers a high-level abstraction for Redis interactions.
      通过Redistemplate可以调用ValueOperations和ListOperations等等方法,分别是对Redis命令的高级封装。
      但是ValueOperations等等这些命令最终是要转化成为RedisCallback来执行的。也就是说通过使用RedisCallback可以实现更强的功能,SDR文档对RedisCallback的介绍:RedisTemplate and StringRedisTemplate allow the developer to talk directly to Redis through the RedisCallback interface. This gives complete control to the developer as it talks directly to the RedisConnection。

    (2)从高级封装获得低级封装的过渡:
    RedisOperations<String, Object> operations = opsForValue.getOperations();

    3、RedisConnection提供了“低级封装”。
    (1)低级封装
    低级封装的操作是通过连接到Redis的Connection对象,直接对Redis数据进行操作。
    低级封装的核心是:redisTemplate.execute(new RedisCallback(){})

    【参考资料】
    01.《Spring Data Redis官方文档》:
    http://docs.spring.io/spring-data/redis/docs/1.7.2.RELEASE/reference/html/

  • 相关阅读:
    谷歌浏览器调试按钮作用
    Android App罕见错误和优化方案
    cordova插件iOS平台实战开发注意点
    xcode8继续愉快的使用插件
    答CsdnBlogger问-关于VR取代安卓的问题
    答CsdnBlogger问-关于职业发展和团队管理问题
    答CsdnBlogger问-关于安卓入行和开发问题
    答CsdnBlogger问-关于定时和后台服务问题
    下载大图的demo by apple,值得研究和参考
    一个不错的mac软件下载站,mark一下 (商业使用请务必支持正版)
  • 原文地址:https://www.cnblogs.com/zjrodger/p/5800593.html
Copyright © 2011-2022 走看看