-
Notifications
You must be signed in to change notification settings - Fork 986
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
96 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/com/lambdaworks/redis/codec/ByteArrayCodec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.lambdaworks.redis.codec; | ||
|
||
import java.nio.ByteBuffer; | ||
|
||
/** | ||
* A {@link RedisCodec} that uses plain byte arrays. | ||
* | ||
* @author <a href="mailto:[email protected]">Mark Paluch</a> | ||
* @since 3.3 | ||
*/ | ||
public class ByteArrayCodec extends RedisCodec<byte[], byte[]> { | ||
|
||
@Override | ||
public byte[] decodeKey(ByteBuffer bytes) { | ||
return getBytes(bytes); | ||
} | ||
|
||
@Override | ||
public byte[] decodeValue(ByteBuffer bytes) { | ||
return getBytes(bytes); | ||
} | ||
|
||
@Override | ||
public byte[] encodeKey(byte[] key) { | ||
return key; | ||
} | ||
|
||
@Override | ||
public byte[] encodeValue(byte[] value) { | ||
return value; | ||
} | ||
|
||
private static byte[] getBytes(ByteBuffer buffer) { | ||
byte[] b = new byte[buffer.remaining()]; | ||
buffer.get(b); | ||
return b; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters