@Override public void rename(String newKey) { generalOps.rename(key, newKey); key = newKey; }
@Override public void rename(String newKey) { generalOps.rename(key, newKey); key = newKey; }
@Override public void rename(String newKey) { generalOps.rename(key, newKey); key = newKey; }
@Override public void rename(K newKey) { if (ops.hasKey(key)) { ops.rename(key, newKey); } key = newKey; } }
private void saveChangeSessionId(String sessionId) { if (!sessionId.equals(this.originalSessionId)) { if (!isNew()) { String originalSessionIdKey = getSessionKey(this.originalSessionId); String sessionIdKey = getSessionKey(sessionId); try { RedisOperationsSessionRepository.this.sessionRedisOperations .rename(originalSessionIdKey, sessionIdKey); } catch (NonTransientDataAccessException ex) { handleErrNoSuchKeyError(ex); } String originalExpiredKey = getExpiredKey(this.originalSessionId); String expiredKey = getExpiredKey(sessionId); try { RedisOperationsSessionRepository.this.sessionRedisOperations .rename(originalExpiredKey, expiredKey); } catch (NonTransientDataAccessException ex) { handleErrNoSuchKeyError(ex); } } this.originalSessionId = sessionId; } }
@SuppressWarnings("unchecked") public Object execute(RedisOperations operations) throws DataAccessException { do { operations.watch(key); if (operations.hasKey(key)) { operations.multi(); operations.rename(key, newKey); } else { operations.multi(); } } while (operations.exec() == null); return null; } });
@Test public void changeSessionIdWhenNotSaved() { given(this.redisOperations.boundHashOps(anyString())) .willReturn(this.boundHashOperations); given(this.redisOperations.boundSetOps(anyString())) .willReturn(this.boundSetOperations); given(this.redisOperations.boundValueOps(anyString())) .willReturn(this.boundValueOperations); RedisSession createSession = this.redisRepository.createSession(); String originalId = createSession.getId(); String changeSessionId = createSession.changeSessionId(); this.redisRepository.save(createSession); verify(this.redisOperations, never()).rename(anyString(), anyString()); assertThat(originalId).isNotEqualTo(changeSessionId); assertThat(createSession.getId()).isEqualTo(createSession.getId()); }
@Test public void changeSessionIdWhenSaved() { given(this.redisOperations.boundHashOps(anyString())) .willReturn(this.boundHashOperations); given(this.redisOperations.boundSetOps(anyString())) .willReturn(this.boundSetOperations); given(this.redisOperations.boundValueOps(anyString())) .willReturn(this.boundValueOperations); RedisSession session = this.redisRepository.new RedisSession(this.cached); session.setLastAccessedTime(session.getLastAccessedTime()); String originalId = session.getId(); String changeSessionId = session.changeSessionId(); this.redisRepository.save(session); verify(this.redisOperations, times(2)).rename(anyString(), anyString()); assertThat(originalId).isNotEqualTo(changeSessionId); assertThat(session.getId()).isEqualTo(session.getId()); }
@Override public void rename(String newKey) { generalOps.rename(key, newKey); key = newKey; }
@Override public void rename(String newKey) { generalOps.rename(key, newKey); key = newKey; }
@Override public void rename(String newKey) { generalOps.rename(key, newKey); key = newKey; }
@Override public void rename(String newKey) { generalOps.rename(key, newKey); key = newKey; }
@Override public void rename(String newKey) { generalOps.rename(key, newKey); key = newKey; }
@Override public void rename(String newKey) { generalOps.rename(key, newKey); key = newKey; }
@Override public void rename(K newKey) { if (ops.hasKey(key)) { ops.rename(key, newKey); } key = newKey; } }
@Override public void rename(K newKey) { if (ops.hasKey(key)) { ops.rename(key, newKey); } key = newKey; } }
@SuppressWarnings("unchecked") public Object execute(RedisOperations operations) throws DataAccessException { do { operations.watch(key); if (operations.hasKey(key)) { operations.multi(); operations.rename(key, newKey); } else { operations.multi(); } } while (operations.exec() == null); return null; } });
@SuppressWarnings("unchecked") public Object execute(RedisOperations operations) throws DataAccessException { do { operations.watch(key); if (operations.hasKey(key)) { operations.multi(); operations.rename(key, newKey); } else { operations.multi(); } } while (operations.exec() == null); return null; } });