Spring Data Key-Value

org.springframework.data.keyvalue.redis.serializer
Class StringRedisSerializer

java.lang.Object
  extended by org.springframework.data.keyvalue.redis.serializer.StringRedisSerializer
All Implemented Interfaces:
RedisSerializer<String>

public class StringRedisSerializer
extends Object
implements RedisSerializer<String>

Simple String to byte[] (and back) serializer. Converts Strings into bytes and vice-versa using the specified charset (by default UTF-8).

Useful when the interaction with the Redis happens mainly through Strings.

Converts null into empty arrays (which get translated into empty strings on deserialization).

Author:
Costin Leau

Constructor Summary
StringRedisSerializer()
           
StringRedisSerializer(Charset charset)
           
 
Method Summary
 String deserialize(byte[] bytes)
          Deserialize an object from the given binary data.
 byte[] serialize(String string)
          Serialize the given object to binary data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringRedisSerializer

public StringRedisSerializer()

StringRedisSerializer

public StringRedisSerializer(Charset charset)
Method Detail

deserialize

public String deserialize(byte[] bytes)
Description copied from interface: RedisSerializer
Deserialize an object from the given binary data.

Specified by:
deserialize in interface RedisSerializer<String>
Parameters:
bytes - object binary representation
Returns:
the equivalent object instance

serialize

public byte[] serialize(String string)
Description copied from interface: RedisSerializer
Serialize the given object to binary data.

Specified by:
serialize in interface RedisSerializer<String>
Parameters:
string - object to serialize
Returns:
the equivalent binary data

Spring Data Key-Value

Copyright © 2010-2011 SpringSource. All Rights Reserved.