Re: spring data redis sort/get issue

222 views
Skip to first unread message

2635...@qq.com

unread,
Jun 21, 2013, 3:54:21 AM6/21/13
to jedis...@googlegroups.com
I got the same case,can you or someone else get and share the relutions??

On Tuesday, April 30, 2013 11:08:29 PM UTC+8, 张斌 wrote:
Hi all, could someone help me.


i'm using spring-data-redis-1.0.3.RELEASE.jar with jedis-2.1.0.jar.

<bean id="jedisConnectionFactory"
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
p:host-name="${redis.host}"
        p:port="${redis.port}"
        p:timeout="${redis.timeout}"
        p:database="${redis.database}"
        p:use-pool="${redis.usePool}"/>
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate"
p:connection-factory-ref="jedisConnectionFactory" />

and i'm using redisTemplate

HashMapper<Item, String, String> itemMapper = new DecoratingStringHashMapper<Item>(new JacksonHashMapper<Item>(Item.class));

SortQuery<String> query = SortQueryBuilder.sort(uid).noSort().get("item:*->name").get("item:*->desc").build();
BulkMapper<Item, String> hm = new BulkMapper<Item, String>() {
@Override
public Item mapBulk(List<String> bulk) {
Map<String, String> map = new LinkedHashMap<String, String>();
Iterator<String> iterator = bulk.iterator();
                                       map.put("name",  iterator.next());
map.put("desc",  iterator.next());
}
return itemMapper.fromHash(map);
}
};
List<Item> result = redisTemplate.sort(query, hm);

if i use JdkSerializationRedisSerializer for key and value, it wont work.  but it works if use StringRedisSerializer

Dose jedis has any restriction on this ?




Reply all
Reply to author
Forward
0 new messages