Reset cache index

This commit is contained in:
Moxie Marlinspike 2019-08-27 14:08:50 -07:00
parent 3803b8f284
commit 20b5f0e681
2 changed files with 13 additions and 13 deletions

View File

@ -140,7 +140,7 @@ public class AccountsManager {
}
private String getAccountEntityKey(UUID uuid) {
return "Account2::" + uuid.toString();
return "Account3::" + uuid.toString();
}
private void redisSet(Account account) {

View File

@ -32,7 +32,7 @@ public class AccountsManagerTest {
when(cacheClient.getReadResource()).thenReturn(jedis);
when(jedis.get(eq("AccountMap::+14152222222"))).thenReturn(uuid.toString());
when(jedis.get(eq("Account2::" + uuid.toString()))).thenReturn("{\"number\": \"+14152222222\", \"name\": \"test\"}");
when(jedis.get(eq("Account3::" + uuid.toString()))).thenReturn("{\"number\": \"+14152222222\", \"name\": \"test\"}");
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheClient);
Optional<Account> account = accountsManager.get("+14152222222");
@ -42,7 +42,7 @@ public class AccountsManagerTest {
assertEquals(account.get().getProfileName(), "test");
verify(jedis, times(1)).get(eq("AccountMap::+14152222222"));
verify(jedis, times(1)).get(eq("Account2::" + uuid.toString()));
verify(jedis, times(1)).get(eq("Account3::" + uuid.toString()));
verify(jedis, times(1)).close();
verifyNoMoreInteractions(jedis);
verifyNoMoreInteractions(accounts);
@ -58,7 +58,7 @@ public class AccountsManagerTest {
UUID uuid = UUID.randomUUID();
when(cacheClient.getReadResource()).thenReturn(jedis);
when(jedis.get(eq("Account2::" + uuid.toString()))).thenReturn("{\"number\": \"+14152222222\", \"name\": \"test\"}");
when(jedis.get(eq("Account3::" + uuid.toString()))).thenReturn("{\"number\": \"+14152222222\", \"name\": \"test\"}");
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheClient);
Optional<Account> account = accountsManager.get(uuid);
@ -68,7 +68,7 @@ public class AccountsManagerTest {
assertEquals(account.get().getUuid(), uuid);
assertEquals(account.get().getProfileName(), "test");
verify(jedis, times(1)).get(eq("Account2::" + uuid.toString()));
verify(jedis, times(1)).get(eq("Account3::" + uuid.toString()));
verify(jedis, times(1)).close();
verifyNoMoreInteractions(jedis);
verifyNoMoreInteractions(accounts);
@ -97,7 +97,7 @@ public class AccountsManagerTest {
verify(jedis, times(1)).get(eq("AccountMap::+14152222222"));
verify(jedis, times(1)).set(eq("AccountMap::+14152222222"), eq(uuid.toString()));
verify(jedis, times(1)).set(eq("Account2::" + uuid.toString()), anyString());
verify(jedis, times(1)).set(eq("Account3::" + uuid.toString()), anyString());
verify(jedis, times(2)).close();
verifyNoMoreInteractions(jedis);
@ -116,7 +116,7 @@ public class AccountsManagerTest {
when(cacheClient.getReadResource()).thenReturn(jedis);
when(cacheClient.getWriteResource()).thenReturn(jedis);
when(jedis.get(eq("Account2::" + uuid))).thenReturn(null);
when(jedis.get(eq("Account3::" + uuid))).thenReturn(null);
when(accounts.get(eq(uuid))).thenReturn(Optional.of(account));
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheClient);
@ -125,9 +125,9 @@ public class AccountsManagerTest {
assertTrue(retrieved.isPresent());
assertSame(retrieved.get(), account);
verify(jedis, times(1)).get(eq("Account2::" + uuid));
verify(jedis, times(1)).get(eq("Account3::" + uuid));
verify(jedis, times(1)).set(eq("AccountMap::+14152222222"), eq(uuid.toString()));
verify(jedis, times(1)).set(eq("Account2::" + uuid.toString()), anyString());
verify(jedis, times(1)).set(eq("Account3::" + uuid.toString()), anyString());
verify(jedis, times(2)).close();
verifyNoMoreInteractions(jedis);
@ -157,7 +157,7 @@ public class AccountsManagerTest {
verify(jedis, times(1)).get(eq("AccountMap::+14152222222"));
verify(jedis, times(1)).set(eq("AccountMap::+14152222222"), eq(uuid.toString()));
verify(jedis, times(1)).set(eq("Account2::" + uuid.toString()), anyString());
verify(jedis, times(1)).set(eq("Account3::" + uuid.toString()), anyString());
verify(jedis, times(2)).close();
verifyNoMoreInteractions(jedis);
@ -176,7 +176,7 @@ public class AccountsManagerTest {
when(cacheClient.getReadResource()).thenReturn(jedis);
when(cacheClient.getWriteResource()).thenReturn(jedis);
when(jedis.get(eq("Account2::" + uuid))).thenThrow(new JedisException("Connection lost!"));
when(jedis.get(eq("Account3::" + uuid))).thenThrow(new JedisException("Connection lost!"));
when(accounts.get(eq(uuid))).thenReturn(Optional.of(account));
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheClient);
@ -185,9 +185,9 @@ public class AccountsManagerTest {
assertTrue(retrieved.isPresent());
assertSame(retrieved.get(), account);
verify(jedis, times(1)).get(eq("Account2::" + uuid));
verify(jedis, times(1)).get(eq("Account3::" + uuid));
verify(jedis, times(1)).set(eq("AccountMap::+14152222222"), eq(uuid.toString()));
verify(jedis, times(1)).set(eq("Account2::" + uuid.toString()), anyString());
verify(jedis, times(1)).set(eq("Account3::" + uuid.toString()), anyString());
verify(jedis, times(2)).close();
verifyNoMoreInteractions(jedis);