add exists vs get test #6

Merged
zeekling merged 1 commits from existsVSget into master 2022-11-12 12:58:51 +00:00
8 changed files with 83 additions and 29 deletions

29
pom.xml
View File

@ -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>

View 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();
}
}

View 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);
}
}

View 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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,2 @@
com/zeekling/redis/RedisDistributedLockTest.class
com/zeekling/redis/RedisPoolTest.class

View File

@ -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