# jedis入门

## jedis入门

* 直接获取链接

```java
//获取连接
Jedis jedis = new Jedis("172.18.115.44", 6380);

Set<String> keys = jedis.keys("*");

for (String key : keys) {

    System.out.println(key);
}
//释放资源
jedis.close();
```

* 使用连接池获取链接

```java
//使用连接池
JedisPoolConfig config = new JedisPoolConfig();
//设置最大连接数
config.setMaxTotal(30);
//设置最大空闲连接数
config.setMaxIdle(10);

JedisPool jedisPool = new JedisPool(config, "172.18.115.44", 6380);
Jedis jedis = jedisPool.getResource();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://db-woms.gitbook.io/db/redis/imooc/imooc-01.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
