Skip to content

Commit 63ee273

Browse files
committed
support select databases
1 parent b342164 commit 63ee273

File tree

13 files changed

+2380
-141
lines changed

13 files changed

+2380
-141
lines changed

.flattened-pom.xml

Lines changed: 0 additions & 35 deletions
This file was deleted.

cache-core/.flattened-pom.xml

Lines changed: 0 additions & 43 deletions
This file was deleted.

cache-core/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
<name>cache-core</name>
1616
<description>cache-core</description>
17+
<packaging>jar</packaging>
1718

1819
<dependencies>
1920
<dependency>

cache-core/src/main/java/cn/ipman/cache/core/command/Commands.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class Commands {
2727
private static void initCommands() {
2828

2929
// common
30+
register(new SelectCommand());
3031
register(new CmdCommand());
3132
register(new PingCommand());
3233
register(new InfoCommand());
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package cn.ipman.cache.core.command.common;
2+
3+
import cn.ipman.cache.core.command.Command;
4+
import cn.ipman.cache.core.core.IMCache;
5+
import cn.ipman.cache.core.core.Reply;
6+
7+
/**
8+
* Description for this class
9+
*
10+
* @Author IpMan
11+
* @Date 2024/6/22 13:27
12+
*/
13+
public class SelectCommand implements Command {
14+
15+
@Override
16+
public String name() {
17+
// SELECT ===> *2,$6,select,$1,0
18+
return "SELECT";
19+
}
20+
21+
@Override
22+
public Reply<?> exec(IMCache cache, String[] args) {
23+
return Reply.string(OK); // 暂不实现select
24+
}
25+
}

cache-core/src/main/resources/application.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.

cache-server/.flattened-pom.xml

Lines changed: 0 additions & 61 deletions
This file was deleted.

cache-server/pom.xml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717
<description>cache-server</description>
1818

1919
<dependencies>
20+
2021
<dependency>
2122
<groupId>org.springframework.boot</groupId>
2223
<artifactId>spring-boot-starter</artifactId>
2324
</dependency>
2425

2526
<dependency>
26-
<groupId>cn.ipman</groupId>
27+
<groupId>io.github.ipipman</groupId>
2728
<artifactId>cache-core</artifactId>
2829
<version>${cache.version}</version>
2930
</dependency>
@@ -66,6 +67,19 @@
6667
<version>3.0.1</version>
6768
<scope>test</scope>
6869
</dependency>
70+
71+
<dependency>
72+
<groupId>redis.clients</groupId>
73+
<artifactId>jedis</artifactId>
74+
<version>2.6.2</version>
75+
</dependency>
76+
77+
<dependency>
78+
<groupId>org.apache.commons</groupId>
79+
<artifactId>commons-pool2</artifactId>
80+
<version>2.6.2</version>
81+
</dependency>
82+
6983
</dependencies>
7084

7185
<build>

cache-server/src/main/java/cn/ipman/cache/server/config/IMApplicationListener.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package cn.ipman.cache.server.config;
22

3+
import cn.ipman.cache.server.jedis.JedisUtil;
34
import cn.ipman.cache.server.server.IMServerPlugin;
45
import lombok.NonNull;
56
import org.springframework.beans.factory.annotation.Autowired;
@@ -27,6 +28,9 @@ public class IMApplicationListener implements ApplicationListener<ApplicationEve
2728
List<IMServerPlugin> plugins;
2829

2930

31+
@Autowired
32+
JedisUtil jedisUtil;
33+
3034
@Override
3135
public void onApplicationEvent(@NonNull ApplicationEvent event) {
3236

@@ -48,6 +52,11 @@ public void onApplicationEvent(@NonNull ApplicationEvent event) {
4852
executor.scheduleWithFixedDelay(() -> {
4953
System.out.println("Netty redis起动后, 定时任务进程ID为 "
5054
+ Thread.currentThread().getId() + ", 父线程ID为 " + inheritableThreadLocal.get());
55+
56+
System.out.println(jedisUtil.set("a", "1", 0));
57+
System.out.println(jedisUtil.get("a", 0));
58+
59+
5160
}, 2, 2, TimeUnit.SECONDS);
5261

5362

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package cn.ipman.cache.server.config;
2+
3+
import org.springframework.beans.factory.annotation.Value;
4+
import org.springframework.boot.context.properties.ConfigurationProperties;
5+
import org.springframework.context.annotation.Bean;
6+
import org.springframework.context.annotation.Configuration;
7+
import redis.clients.jedis.JedisPool;
8+
import redis.clients.jedis.JedisPoolConfig;
9+
10+
11+
/**
12+
* Created by ipipman on 2021/1/6.
13+
*
14+
* @version V1.0
15+
* @Package com.ipman.springboot.redis.jedis.sample.config
16+
* @Description: (用一句话描述该文件做什么)
17+
* @date 2021/1/6 10:11 下午
18+
*/
19+
@Configuration
20+
public class JedisConfig {
21+
22+
@Value("${spring.data.redis.host}")
23+
private String host;
24+
25+
@Value("${spring.data.redis.port}")
26+
private int port;
27+
28+
@Value("${spring.data.redis.timeout}")
29+
private int timeout;
30+
31+
@Bean
32+
@ConfigurationProperties("spring.data.redis")
33+
public JedisPoolConfig jedisPoolConfig() {
34+
System.out.println("jedisPoolConfig staring...");
35+
return new JedisPoolConfig();
36+
}
37+
38+
@Bean(destroyMethod = "close")
39+
public JedisPool jedisPool() {
40+
return new JedisPool(jedisPoolConfig(), host, port, timeout * 1000);
41+
}
42+
}

0 commit comments

Comments
 (0)