
1、执行如图是命令,查看redis服务是否启动。
2、执行命令“redis-cli”进入redis命令行界面。
3、执行命令“dbsize”。
4、执行命令“flushall”刷新清除。
5、执行命令“ keys * ”进行验证redis是否为空,可以看到redi数据。
redis提供了灵活的数据查询方式,最牛的就是key的搜索支持正则表达式。jedis.keys(“*”)表示搜索所有key
jedis.keys(“abc*”)表示搜索开头为abc的key数据
遍历了key就能遍历到value。
其实就是一个set
复制代码代码如下:
RedisDO rd = new RedisDO()
rd.open()
Set s = rd.jedis.keys("*")
Iterator it = s.iterator()
while (it.hasNext()) {
String key = (String) it.next()
String value = rd.jedis.get(key)
System.out.println(key + value)
}
rd.close()
rd的算法为集成redis 运算
复制代码代码如下:
package com.javaer.click.way
import redis.clients.jedis.Jedis
import redis.clients.jedis.JedisPool
import redis.clients.jedis.JedisPoolConfig
import redis.clients.jedis.exceptions.JedisConnectionException
public class RedisDO {
public Jedis jedis
public void close(){
jedis.disconnect()
jedis = null
}
public Jedis open(){
JedisPoolConfig config = new JedisPoolConfig()
config.setMaxActive(100)
config.setMaxIdle(20)
config.setMaxWait(1000l)
JedisPool pool
pool = new JedisPool(config, "xxxxxxxx.xx.xx.xx", 6379)
boolean borrowOrOprSuccess = true
try {
jedis = pool.getResource()
// do redis opt by instance
} catch (JedisConnectionException e) {
borrowOrOprSuccess = false
if (jedis != null)
pool.returnBrokenResource(jedis)
} finally {
if (borrowOrOprSuccess)
pool.returnResource(jedis)
}
jedis = pool.getResource()
return jedis
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
在NoSQL数据库中,具体的 *** 作方式因数据库类型而异。以下是几种常见的NoSQL数据库及其显示当前数据库的方法:1. MongoDB数据库:使用命令show dbs可以显示当前所有数据库。
2. Redis数据库:使用命令info或者命令select命令可以查看当前使用的数据库。
3. Couchbase数据库:使用命令select * from system:keyspaces可以查看当前所有存储桶(类似于关系型数据库中的表)。
4. Cassandra数据库:使用命令DESCRIBE KEYSPACES可以查看所有键空间(类似于关系型数据库中的数据库)。
总之,在NoSQL数据库中,显示当前数据库的具体 *** 作方式需要依据具体的数据库类型而定。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)