Merge pull request #1028 from sulake/fixes

Revert changes to StringCodec and fix script compilation.
pull/1032/merge
Nikita Koksharov 8 years ago committed by GitHub
commit e606419633

@ -200,7 +200,7 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
args.add(maxSize); args.add(maxSize);
args.addAll(keys); args.addAll(keys);
return commandExecutor.evalWriteAsync(getName(), codec, new RedisCommand<Map<Object, Object>>("EVAL", new MapGetAllDecoder(args, 2), 7, ValueType.MAP_KEY, ValueType.MAP_VALUE), return commandExecutor.evalWriteAsync(getName(), codec, new RedisCommand<Map<Object, Object>>("EVAL", new MapGetAllDecoder(args, 2), 8, ValueType.MAP_KEY, ValueType.MAP_VALUE),
"local expireHead = redis.call('zrange', KEYS[2], 0, 0, 'withscores'); " + "local expireHead = redis.call('zrange', KEYS[2], 0, 0, 'withscores'); " +
"local currentTime = tonumber(table.remove(ARGV, 1)); " + // index is the first parameter "local currentTime = tonumber(table.remove(ARGV, 1)); " + // index is the first parameter
"local maxSize = tonumber(table.remove(ARGV, 1)); " + // index is the first parameter "local maxSize = tonumber(table.remove(ARGV, 1)); " + // index is the first parameter
@ -347,7 +347,7 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
" local msg = struct.pack('Lc0Lc0', string.len(lruItem), lruItem, string.len(lruItemValue), lruItemValue); " + " local msg = struct.pack('Lc0Lc0', string.len(lruItem), lruItem, string.len(lruItemValue), lruItemValue); " +
" redis.call('publish', removedChannelName, msg); " + " redis.call('publish', removedChannelName, msg); " +
" end; " + " end; " +
" end" + " end; " +
" end; " + " end; " +
"end; " "end; "
@ -584,7 +584,7 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
" local msg = struct.pack('Lc0Lc0', string.len(lruItem), lruItem, string.len(lruItemValue), lruItemValue); " + " local msg = struct.pack('Lc0Lc0', string.len(lruItem), lruItem, string.len(lruItemValue), lruItemValue); " +
" redis.call('publish', removedChannelName, msg); " + " redis.call('publish', removedChannelName, msg); " +
" end; " + " end; " +
" end" + " end; " +
" end; " + " end; " +
"end; " "end; "
@ -662,7 +662,7 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
" local msg = struct.pack('Lc0Lc0', string.len(lruItem), lruItem, string.len(lruItemValue), lruItemValue); " + " local msg = struct.pack('Lc0Lc0', string.len(lruItem), lruItem, string.len(lruItemValue), lruItemValue); " +
" redis.call('publish', removedChannelName, msg); " + " redis.call('publish', removedChannelName, msg); " +
" end; " + " end; " +
" end" + " end; " +
" end; " + " end; " +
"end; " "end; "
@ -794,7 +794,7 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
" local msg = struct.pack('Lc0Lc0', string.len(lruItem), lruItem, string.len(lruItemValue), lruItemValue); " + " local msg = struct.pack('Lc0Lc0', string.len(lruItem), lruItem, string.len(lruItemValue), lruItemValue); " +
" redis.call('publish', removedChannelName, msg); " + " redis.call('publish', removedChannelName, msg); " +
" end; " + " end; " +
" end" + " end; " +
" end; " + " end; " +
"end; " "end; "
@ -930,7 +930,7 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
" local msg = struct.pack('Lc0Lc0', string.len(lruItem), lruItem, string.len(lruItemValue), lruItemValue); " + " local msg = struct.pack('Lc0Lc0', string.len(lruItem), lruItem, string.len(lruItemValue), lruItemValue); " +
" redis.call('publish', removedChannelName, msg); " + " redis.call('publish', removedChannelName, msg); " +
" end; " + " end; " +
" end" + " end; " +
" end; " + " end; " +
"end; " "end; "
@ -1279,7 +1279,7 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
" local msg = struct.pack('Lc0Lc0', string.len(lruItem), lruItem, string.len(lruItemValue), lruItemValue); " + " local msg = struct.pack('Lc0Lc0', string.len(lruItem), lruItem, string.len(lruItemValue), lruItemValue); " +
" redis.call('publish', removedChannelName, msg); " + " redis.call('publish', removedChannelName, msg); " +
" end; " + " end; " +
" end" + " end; " +
" end; " + " end; " +
"end; " "end; "
@ -1329,7 +1329,7 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
" local msg = struct.pack('Lc0Lc0', string.len(lruItem), lruItem, string.len(lruItemValue), lruItemValue); " + " local msg = struct.pack('Lc0Lc0', string.len(lruItem), lruItem, string.len(lruItemValue), lruItemValue); " +
" redis.call('publish', removedChannelName, msg); " + " redis.call('publish', removedChannelName, msg); " +
" end; " + " end; " +
" end" + " end; " +
" end; " + " end; " +
"end; " "end; "
@ -1475,7 +1475,7 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
" local msg = struct.pack('Lc0Lc0', string.len(lruItem), lruItem, string.len(lruItemValue), lruItemValue); " + " local msg = struct.pack('Lc0Lc0', string.len(lruItem), lruItem, string.len(lruItemValue), lruItemValue); " +
" redis.call('publish', removedChannelName, msg); " + " redis.call('publish', removedChannelName, msg); " +
" end; " + " end; " +
" end" + " end; " +
" end; " + " end; " +
" end; " + " end; " +
// value // value

@ -18,7 +18,6 @@ package org.redisson.client.codec;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import io.netty.buffer.ByteBufUtil;
import org.redisson.client.handler.State; import org.redisson.client.handler.State;
import org.redisson.client.protocol.Decoder; import org.redisson.client.protocol.Decoder;
import org.redisson.client.protocol.Encoder; import org.redisson.client.protocol.Encoder;
@ -41,17 +40,10 @@ public class StringCodec implements Codec {
private final Encoder encoder = new Encoder() { private final Encoder encoder = new Encoder() {
@Override @Override
public ByteBuf encode(Object in) throws IOException { public ByteBuf encode(Object in) throws IOException {
if (CharsetUtil.UTF_8.equals(charset)) {
String payload = in.toString();
ByteBuf buf = ByteBufAllocator.DEFAULT.buffer(ByteBufUtil.utf8MaxBytes(payload));
ByteBufUtil.writeUtf8(buf, payload);
return buf;
} else {
ByteBuf out = ByteBufAllocator.DEFAULT.buffer(); ByteBuf out = ByteBufAllocator.DEFAULT.buffer();
out.writeCharSequence(in.toString(), charset); out.writeCharSequence(in.toString(), charset);
return out; return out;
} }
}
}; };
private final Decoder<Object> decoder = new Decoder<Object>() { private final Decoder<Object> decoder = new Decoder<Object>() {

Loading…
Cancel
Save