Skip to content

Commit 955941c

Browse files
author
Costin Leau
committed
Merge branch 'lettuce'
2 parents 0b70fa2 + e631af2 commit 955941c

16 files changed

+2478
-36
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ dependencies {
4646
compile("com.github.spullara.redis:client:$srpVersion", optional)
4747
compile("org.jredis:jredis-anthonylauzon:$jredisVersion", optional)
4848
compile("org.idevlab:rjc:$rjcVersion", optional)
49+
compile("com.lambdaworks:lettuce:$lettuceVersion", optional)
4950

5051
// Mappers
5152
compile("org.codehaus.jackson:jackson-mapper-asl:$jacksonVersion", optional)

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jedisVersion = 2.1.0
1717
jredisVersion = 03122010
1818
rjcVersion = 0.6.4
1919
srpVersion = 0.2
20+
lettuceVersion = 2.2.0
2021

2122
# --------------------
2223
# Project wide version
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright 2011-2013 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.data.redis.connection.lettuce;
18+
19+
import java.nio.ByteBuffer;
20+
21+
import com.lambdaworks.redis.codec.RedisCodec;
22+
23+
/**
24+
* Basic codec that returns the raw data as byte[].
25+
*
26+
* @author Costin Leau
27+
*/
28+
class BytesRedisCodec extends RedisCodec<byte[], byte[]> {
29+
30+
@Override
31+
public byte[] decodeKey(ByteBuffer bytes) {
32+
return getBytes(bytes);
33+
}
34+
35+
@Override
36+
public byte[] decodeValue(ByteBuffer bytes) {
37+
return getBytes(bytes);
38+
}
39+
40+
@Override
41+
public byte[] encodeKey(byte[] key) {
42+
return key;
43+
}
44+
45+
@Override
46+
public byte[] encodeValue(byte[] value) {
47+
return value;
48+
}
49+
50+
private static byte[] getBytes(ByteBuffer buffer) {
51+
byte[] b = new byte[buffer.remaining()];
52+
buffer.get(b);
53+
return b;
54+
}
55+
}

0 commit comments

Comments
 (0)