-
redis hash怎么用
- public static void testHsh() {
- System.out.println("==Hash==");
- Jedis jedis = RedisUtil.getJedis();
- try {
- Map<String, String> pairs = new HashMap<String, String>();
- pairs.put("name", "Akshi");
- pairs.put("age", "2");
- pairs.put("sex", "Female");
- jedis.hmset("kid", pairs);
- List<String> name = jedis.hmget("kid", "name");
-
- System.out.println(jedis.hmget("kid", "pwd"));
- System.out.println(jedis.hlen("kid"));
- System.out.println(jedis.exists("kid"));
- System.out.println(jedis.hkeys("kid"));
- System.out.println(jedis.hvals("kid"));
-
- Iterator<String> iter = jedis.hkeys("kid").iterator();
- while (iter.hasNext()) {
- String key = iter.next();
- System.out.println(key + ":" + jedis.hmget("kid", key));
- }
-
- List<String> values = jedis.lrange("messages", 0, -1);
- values = jedis.hmget("kid", new String[] { "name", "age", "sex" });
- System.out.println(values);
- Set<String> setValues = jedis.zrange("hackers", 0, -1);
- setValues = jedis.hkeys("kid");
- System.out.println(setValues);
- values = jedis.hvals("kid");
- System.out.println(values);
- pairs = jedis.hgetAll("kid");
- System.out.println(pairs);
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- RedisUtil.getPool().returnResource(jedis);
- }
-
-
- System.out.println(jedis.flushDB());
-
- jedis.hset("hashs", "entryKey", "entryValue");
- jedis.hset("hashs", "entryKey1", "entryValue1");
- jedis.hset("hashs", "entryKey2", "entryValue2");
-
- System.out.println(jedis.hexists("hashs", "entryKey"));
-
- System.out.println(jedis.hget("hashs", "entryKey"));
- System.out.println(jedis.hmget("hashs", "entryKey", "entryKey1"));
-
- System.out.println(jedis.hdel("hashs", "entryKey"));
-
- System.out.println(jedis.hincrBy("hashs", "entryKey", 123l));
-
- System.out.println(jedis.hkeys("hashs"));
-
- System.out.println(jedis.hvals("hashs"));
- }
-
-
相关阅读:
实验二、作业调度模拟实验
实验一
0909 初识操作系统
实验四、主存空间的分配和回收模拟
12.27评论5位同学试验三
实验三进程调度模拟程序
实验二、作业调度模拟实验
实验一报告
实验四 主存空间的分配和回收模拟
实验三 进程调度模拟程序
-
原文地址:https://www.cnblogs.com/panxuejun/p/6225795.html
Copyright © 2020-2023
润新知