microsphere-projects / microsphere-redis

The microsphere projects for Redis
Apache License 2.0
2 stars 8 forks source link

RedisCommandReplicator Native method implementation #2

Open liqi19950722 opened 7 months ago

liqi19950722 commented 7 months ago

把MethodHandle 存储在一个static final 的map中 再根据方法签名找到对应的Methodhandle 再用invokeWithArguments执行redis命令

Object[] args = new Object[3];
args[0] = connection.stringCommands(); 
args[1] = "key".getBytes(StandardCharsets.UTF_8);
args[2] = "value".getBytes(StandardCharsets.UTF_8);
methodhandle.invokeWithArguments(args);

https://github.com/liqi19950722/redis-testcontainers/blob/master/src/main/java/io/github/fun/stuff/redis/RedisCommandsMethodHandles.java

https://github.com/liqi19950722/redis-testcontainers/blob/master/src/test/java/io/github/fun/stuff/redis/RedisConnectionTest.java

jmh Benchmark: https://github.com/liqi19950722/fun-stuff-reflect

mercyblitz commented 7 months ago

Please Pull request!