Spring Data Redis 2.2.6

Spring Data Redis, part of the larger Spring Data family, provides easy configuration and access to Redis from Spring applications. It offers both low-level and high-level abstractions for interacting with the store, freeing the user from infrastructural concerns.
Features

Connection package as low-level abstraction across multiple Redis drivers(Lettuce and Jedis).

Exception translation to Spring’s portable Data Access exception hierarchy for Redis driver exceptions.

RedisTemplate that provides a high-level abstraction for performing various Redis operations, exception translation and serialization support.

Pubsub support (such as a MessageListenerContainer for message-driven POJOs).

Redis Sentinel and Redis Cluster support.

Reactive API using the Lettuce driver.

JDK, String, JSON and Spring Object/XML mapping serializers.

JDK Collection implementations on top of Redis.

Atomic counter support classes.

Sorting and Pipelining functionality.

Dedicated support for SORT, SORT/GET pattern and returned bulk values.

Redis implementation for Spring 3.1 cache abstraction.

Automatic implementation of Repository interfaces including support for custom query methods using @EnableRedisRepositories.

CDI support for repositories.

Configure RedisTemplate….

Inject and use RedisTemplate or any of its opsForX() instances….

public class Example {

// inject the actual template
@Autowired
private RedisTemplate<String, String> template;

// inject the template as ListOperations
// can also inject as Value, Set, ZSet, and HashOperations
@Resource(name="redisTemplate")
private ListOperations<String, String> listOps;

public void addLink(String userId, URL url) {
    listOps.leftPush(userId, url.toExternalForm());
    // or use template directly
    redisTemplate.boundListOps(userId).leftPush(url.toExternalForm());
}

}

Spring Initializr
Quickstart Your Project
Bootstrap your application with Spring Initializr.

translate:
翻译:

Spring数据Redis是更大Spring数据系列的一部分,它提供了从Spring应用程序轻松配置和访问Redis的功能。它提供了与商店交互的低层和高层抽象,让用户从基础设施问题中解放出来。

特征

连接包作为跨多个Redis驱动程序(生菜和绝地)的低级抽象。

针对Redis驱动程序异常,将异常转换为Spring的可移植数据访问异常层次结构。

RedisTemplate,为执行各种Redis操作、异常转换和序列化支持提供高级抽象。

Pubsub支持(例如消息驱动pojo的MessageListenerContainer)。

Redis Sentinel和Redis集群支持。

使用生菜驱动程序的反应式API。

JDK、String、JSON和Spring对象/XML映射序列化程序。

Redis之上的JDK集合实现。

原子计数器支持类。

排序和流水线功能。

专门支持排序、排序/获取模式和返回的批量值。

Spring 3.1缓存抽象的Redis实现。

存储库接口的自动实现,包括使用@enableredispositories支持自定义查询方法。

对存储库的CDI支持。

配置RedisTemplate…。

<bean id=“绝地武士工厂”

class=“org.springframework.data.redis.connection.jedis.JedisConnectionFactory”

p: 使用pool=”true“/>

<bean id=“重新发现模板”

class=“org.springframework.data.redis.core.RedisTemplate”

p: 连接工厂ref=“jedisConnFactory”/>

注入并使用RedisTemplate或其任何opsForX()实例…。

公共类示例{

//注入实际模板

@自动连线

私有RedisTemplate<String,String>模板;

//将模板作为listooperations注入

//也可以作为值、Set、ZSet和HashOperations注入

@资源(name=“redisTemplate”)

私有列表操作<String,String>listOps;

public void addLink(字符串userId,URL URL){

listOps.leftPush(用户id,url.toExternalForm());

//或者直接使用模板

redisTemplate.boundListOps(userId).leftPush(url.toExternalForm());

}

}

弹簧初始化器

快速启动项目

使用Spring初始化器引导应用程序。

发布了0 篇原创文章 · 获赞 152 · 访问量 7070

猜你喜欢

转载自blog.csdn.net/blog_programb/article/details/105242506