RedisSessionRepository implements SessionRepository { @Override public Set<String> getAllKeys(SessionData session) { Set<String> keys = new HashSet<>(); for (byte[] key : redis.hkeys(sessionKey(session))) { if (!hasInternalPrefix(key)) { keys.add(encode(key)); } } return Collections.unmodifiableSet(keys); } RedisSessionRepository(RedisFacade redis, String namespace, String owner, ExpirationStrategy strategy,
      boolean sticky); @Override void setSessionManager(final SessionManager sessionManager); @Override SessionData getSessionData(String id); @Override CommitTransaction startCommit(SessionData session); @Override void remove(SessionData session); byte[] sessionKey(String sessionId); @Override Object getSessionAttribute(SessionData session, String attribute); @Override boolean prepareRemove(SessionData session); @Override Set<String> getAllKeys(SessionData session); @Override void storeSessionData(SessionData sessionData); @Override void requestFinished(); @Override void setSessionAttribute(SessionData session, String name, Object value); @Override void removeSessionAttribute(SessionData session, String name); @Override boolean cleanSessionsOnShutdown(); @Override Collection<String> getOwnedSessionIds(); @Override void close(); @Override void reset(); @Override void sessionIdChange(SessionData sessionData); @Override boolean isConnected();  }
@Test public void testGetAllKeys() { RedisFacade facade = mock(RedisFacade.class); try (RedisSessionRepository rsr = new RedisSessionRepository(facade, "myapp", "localhost", ExpirationStrategy.ZRANGE, false)) { Set<byte[]> result = Collections.singleton(new byte[] { 65 }); when(facade.hkeys(rsr.sessionKey("400"))).thenReturn(result); Set<String> s = rsr.getAllKeys(new SessionData("400", 100, 10)); assertEquals(1, s.size()); assertEquals("A", s.toArray()[0]); verify(facade, times(1)).hkeys(rsr.sessionKey("400")); } }