async-redis-client's People
async-redis-client's Issues
多线程调用导致的并发冲突
测试代码
final AsyncRedisClient client = new NettyRedisClient("192.168.1.246:6379", 1, null);
for (int i = 0; i < 20; i++) {
new Thread(new Runnable() {
@Override
public void run() {
for (int count = 0; count < 100; count++) {
String key = randomString(5);
String value = randomString(10);
try {
String status = client.set(key, value).get();
if("OK".equals(status)) {
String redisValue = (String) client.get(key).get();
if (!value.equals(redisValue)) {
System.out.println("expected value " + value + ",but return " + redisValue);
}
} else {
System.out.println("expected set directive return OK,but return " + status);
}
} catch (Exception e) {
e.printStackTrace();
//Thread.currentThread().interrupt();
}
}
}
}).start();
}
private static Random randGen = new SecureRandom();
private static char[] numbersAndLetters = ("0123456789abcdefghijklmnopqrstuvwxyz" +
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ").toCharArray();
public static final String randomString(int length) {
if (length < 1) {
return null;
}
// Create a char buffer to put random letters and numbers in.
char [] randBuffer = new char[length];
for (int i=0; i<randBuffer.length; i++) {
randBuffer[i] = numbersAndLetters[randGen.nextInt(71)];
}
return new String(randBuffer);
}
主要原因是NettyRedisClient中得writeRequested方法没有加锁,command进队列与调用netty发送数据不是一个原子操作
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.