add exists vs get test
This commit is contained in:
parent
b9a4ec0855
commit
30838bd826
29
pom.xml
29
pom.xml
@ -35,25 +35,6 @@
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.8.5</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>prepare-agent</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>report</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>report</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
@ -62,16 +43,6 @@
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<redis-hosts>${redis-hosts}</redis-hosts>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
37
src/main/java/com/zeekling/redis/speed/ExistsVSGet.java
Normal file
37
src/main/java/com/zeekling/redis/speed/ExistsVSGet.java
Normal file
@ -0,0 +1,37 @@
|
||||
package com.zeekling.redis.speed;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
/**
|
||||
* @author zeekling
|
||||
*/
|
||||
public class ExistsVSGet {
|
||||
|
||||
private static final Jedis jedis = new Jedis("127.0.0.1", 6379);
|
||||
|
||||
private static void exists() {
|
||||
long begin = System.nanoTime();
|
||||
jedis.exists("key_aaaaaaa");
|
||||
long end = System.nanoTime();
|
||||
System.out.println("exists cost=" + (end - begin)/1000);
|
||||
}
|
||||
private static void get() {
|
||||
long begin = System.nanoTime();
|
||||
jedis.exists("key_aaaaaaa");
|
||||
long end = System.nanoTime();
|
||||
System.out.println("get cost=" + (end - begin)/1000);
|
||||
}
|
||||
|
||||
private static void test() {
|
||||
for (int i=1; i< 10; i++) {
|
||||
jedis.get("0000000" + i);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
ExistsVSGet.test();
|
||||
ExistsVSGet.get();
|
||||
ExistsVSGet.exists();
|
||||
}
|
||||
|
||||
}
|
29
src/main/java/com/zeekling/redis/speed/FillData.java
Normal file
29
src/main/java/com/zeekling/redis/speed/FillData.java
Normal file
@ -0,0 +1,29 @@
|
||||
package com.zeekling.redis.speed;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.params.SetParams;
|
||||
|
||||
/**
|
||||
* @author zeekling
|
||||
*/
|
||||
public class FillData {
|
||||
|
||||
private static final Jedis jedis = new Jedis("127.0.0.1", 6379);
|
||||
|
||||
private static void fillData(long min, long max, SetParams params) {
|
||||
for (long i = min; i < max; i++) {
|
||||
jedis.set("key_0000000" + i, "value_0000000" + i, params);
|
||||
if (i % 1000 == 0) {
|
||||
System.out.println("count=" + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SetParams params = new SetParams();
|
||||
FillData.fillData(0, 5000000, params);
|
||||
params.ex(50000L);
|
||||
FillData.fillData(50000000, 55000000, params);
|
||||
}
|
||||
|
||||
}
|
5
target/maven-archiver/pom.properties
Normal file
5
target/maven-archiver/pom.properties
Normal file
@ -0,0 +1,5 @@
|
||||
#Generated by Maven
|
||||
#Thu Nov 10 22:51:03 HKT 2022
|
||||
groupId=com.zeekling.redis
|
||||
artifactId=jedis-test
|
||||
version=1.0-SNAPSHOT
|
@ -0,0 +1,4 @@
|
||||
com/zeekling/redis/lock/RedisDistributedLockImpl.class
|
||||
com/zeekling/redis/JedisClusterTest.class
|
||||
com/zeekling/redis/RedisPool.class
|
||||
com/zeekling/redis/lock/DistributedLock.class
|
@ -0,0 +1,4 @@
|
||||
/home/zeekling/project/gitea/redis-test/src/main/java/com/zeekling/redis/lock/RedisDistributedLockImpl.java
|
||||
/home/zeekling/project/gitea/redis-test/src/main/java/com/zeekling/redis/JedisClusterTest.java
|
||||
/home/zeekling/project/gitea/redis-test/src/main/java/com/zeekling/redis/lock/DistributedLock.java
|
||||
/home/zeekling/project/gitea/redis-test/src/main/java/com/zeekling/redis/RedisPool.java
|
@ -0,0 +1,2 @@
|
||||
com/zeekling/redis/RedisDistributedLockTest.class
|
||||
com/zeekling/redis/RedisPoolTest.class
|
@ -0,0 +1,2 @@
|
||||
/home/zeekling/project/gitea/redis-test/src/test/java/com/zeekling/redis/RedisDistributedLockTest.java
|
||||
/home/zeekling/project/gitea/redis-test/src/test/java/com/zeekling/redis/RedisPoolTest.java
|
Loading…
Reference in New Issue
Block a user