Java Code Examples for org.springframework.data.redis.core.BoundHashOperations#get()
The following examples show how to use
org.springframework.data.redis.core.BoundHashOperations#get() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedisTest.java From leyou with Apache License 2.0 | 6 votes |
@Test public void testHash() { BoundHashOperations<String, Object, Object> hashOps = this.redisTemplate.boundHashOps("user"); // 操作hash数据 hashOps.put("name", "jack"); hashOps.put("age", "21"); // 获取单个数据 Object name = hashOps.get("name"); System.out.println("name = " + name); // 获取所有数据 Map<Object, Object> map = hashOps.entries(); for (Map.Entry<Object, Object> me : map.entrySet()) { System.out.println(me.getKey() + " : " + me.getValue()); } }
Example 2
Source File: RegController.java From push with Apache License 2.0 | 6 votes |
@PostMapping("keep") public ServerNode keep(@RequestParam String id, @RequestParam(required = false) String ip, @RequestParam String port, HttpServletRequest request) { BoundHashOperations imKeep = getNodes(); ServerNode serverNode = null; if (!imKeep.hasKey(id)) { serverNode = new ServerNode(); serverNode.setId(id); if (StringUtils.isEmpty(ip)) ip = IpUtil.getIpAddr(request); serverNode.setUrl(ip + ":" + port); serverNode.setLastCheckTime(System.currentTimeMillis()); } else { serverNode = (ServerNode) imKeep.get(id); serverNode.setLastCheckTime(System.currentTimeMillis()); } logger.debug("keep:{} {} {}", id, ip, port); imKeep.put(id, serverNode); return serverNode; }
Example 3
Source File: RedisCacheManager.java From ssm with Apache License 2.0 | 5 votes |
@Override public V remove(K key) throws CacheException { BoundHashOperations<String,K,V> hash = redisTemplate.boundHashOps(cacheKey); Object k=hashKey(key); V value=hash.get(k); hash.delete(k); return value; }
Example 4
Source File: RedissonAutoConfigurationTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testApp() { redisson.getKeys().flushall(); RMap<String, String> m = redisson.getMap("test", StringCodec.INSTANCE); m.put("1", "2"); BoundHashOperations<String, String, String> hash = template.boundHashOps("test"); String t = hash.get("1"); assertThat(t).isEqualTo("2"); }
Example 5
Source File: RedisCacheManager.java From ssm with Apache License 2.0 | 4 votes |
@Override public V get(K key) throws CacheException { BoundHashOperations<String,K,V> hash = redisTemplate.boundHashOps(cacheKey); Object k=hashKey(key); return hash.get(k); }
Example 6
Source File: RedisSessionRegistry.java From albedo with GNU Lesser General Public License v3.0 | 4 votes |
public Set<String> putIfAbsentPrincipals(Object principal, final Set<String> set) { UserDetail userDetail = (UserDetail) principal; BoundHashOperations<String, String, Set<String>> hashOperations = redisTemplate.boundHashOps(PRINCIPALS); hashOperations.putIfAbsent(userDetail.getId(), set); return hashOperations.get(userDetail.getId()); }