스프링 데이터 레디스

in kr-dev •  2 years ago 

더 큰 Spring Data 제품군의 일부인 Spring Data Redis는 Spring 애플리케이션에서 Redis에 대한 쉬운 구성 및 액세스를 제공합니다. 상점과의 상호작용을 위한 저수준 및 고수준 추상화를 모두 제공하여 사용자를 인프라 문제로부터 해방시킵니다.

특징

  • 여러 Redis 드라이버( LettuceJedis ) 에 대한 저수준 추상화로 연결 패키지 .

  • Redis 드라이버 예외에 대한 Spring의 이식 가능한 데이터 액세스 예외 계층으로의 예외 변환.

  • 다양한 Redis 작업, 예외 변환 및 직렬화 지원을 수행하기 위한 높은 수준의 추상화를 제공하는 RedisTemplate 입니다.

  • Pubsub 지원(예: 메시지 기반 POJO용 MessageListenerContainer).

  • Redis SentinelRedis 클러스터 지원.

  • Lettuce 드라이버를 사용하는 반응형 API.

  • JDK, 문자열, JSON 및 Spring Object/XML 매핑 직렬 변환기 .

  • Redis를 기반으로 하는 JDK 컬렉션 구현.

  • 원자 카운터 지원 클래스.

  • 정렬 및 파이프라이닝 기능.

  • SORT, SORT/GET 패턴 및 반환된 대량 값에 대한 전용 지원.

  • Spring 3.1 캐시 추상화를 위한 Redis 구현 .

  • Repository를 사용한 사용자 정의 쿼리 방법 지원을 포함한 인터페이스 @EnableRedisRepositories의 자동 구현

  • 리포지토리에 대한 CDI 지원.

RedisTemplate 구성…

<bean id="jedisConnFactory"
    class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
    p:use-pool="true"/>

(html comment removed:  redis template definition )
<bean id="redisTemplate"
    class="org.springframework.data.redis.core.RedisTemplate"
    p:connection-factory-ref="jedisConnFactory"/>

RedisTemplate 또는 opsForX() 인스턴스를 주입하고 사용합니다.

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());
    }
}

출처 : https://spring.io/projects/spring-data-redis

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

[광고] STEEM 개발자 커뮤니티에 참여 하시면, 다양한 혜택을 받을 수 있습니다.