Class RedisItemWriter<K,T>

java.lang.Object
org.springframework.batch.infrastructure.item.KeyValueItemWriter<K,T>
org.springframework.batch.infrastructure.item.redis.RedisItemWriter<K,T>
All Implemented Interfaces:
ItemWriter<T>, org.springframework.beans.factory.InitializingBean

public class RedisItemWriter<K,T> extends KeyValueItemWriter<K,T>

An ItemWriter implementation for Redis using a RedisTemplate .

Since:
5.1
Author:
Santiago Molano, Mahmoud Ben Hassine, Stefano Cordio
  • Constructor Details

    • RedisItemWriter

      public RedisItemWriter(org.springframework.core.convert.converter.Converter<T,K> itemKeyMapper, org.springframework.data.redis.core.RedisTemplate<K,T> redisTemplate)
      Create a new RedisItemWriter.
      Parameters:
      itemKeyMapper - the Converter used to derive a key from an item.
      redisTemplate - the RedisTemplate to use to interact with Redis.
      Since:
      6.0
  • Method Details

    • writeKeyValue

      protected void writeKeyValue(K key, T value)
      Description copied from class: KeyValueItemWriter
      Subclasses implement this method to write each item to key value store
      Specified by:
      writeKeyValue in class KeyValueItemWriter<K,T>
      Parameters:
      key - the key
      value - the item
    • init

      protected void init()
      Description copied from class: KeyValueItemWriter
      afterPropertiesSet() hook
      Specified by:
      init in class KeyValueItemWriter<K,T>
    • setRedisTemplate

      public void setRedisTemplate(org.springframework.data.redis.core.RedisTemplate<K,T> redisTemplate)
      Set the RedisTemplate to use.
      Parameters:
      redisTemplate - the template to use