@Test public void remove() throws Exception { TokenCache cache = new TokenCache(TokenCache.ExpirationPolicy.WRITE, 120, null); cache.put("foo", "bar"); cache.put("foo", "baz"); assertTrue(cache.get("foo", "bar")); assertTrue(cache.get("foo", "baz")); assertEquals(1, cache.remove("foo", "bar")); assertFalse(cache.get("foo", "bar")); assertTrue(cache.get("foo", "baz")); cache.evict("foo"); assertFalse(cache.get("foo", "bar")); assertFalse(cache.get("foo", "baz")); }
public int remove(@Nonnull String name, @Nonnull String secret) { ConcurrentHashMap<String, Long> userTokens = cache.computeIfAbsent(name, (k) -> buildCache()); userTokens.remove(secret); return userTokens.size(); }
TokenCache implements Closeable { public int remove(@Nonnull String name, @Nonnull String secret) { ConcurrentHashMap<String, Long> userTokens = cache.computeIfAbsent(name, (k) -> buildCache()); userTokens.remove(secret); return userTokens.size(); } }
TokenCache implements Closeable { public int remove(@Nonnull String name, @Nonnull String secret) { ConcurrentHashMap<String, Long> userTokens = cache.computeIfAbsent(name, (k) -> buildCache()); userTokens.remove(secret); return userTokens.size(); } @JsonCreator  TokenCache(@JsonProperty(value = "policy", required = true) ExpirationPolicy policy,
                      @JsonProperty(value = "timeout", required = true) @Time(TimeUnit.SECONDS) int timeout,
                      @JsonProperty("outputPath") Path outputPath); }
TokenCache implements Closeable { public int remove(@Nonnull String name, @Nonnull String secret) { ConcurrentHashMap<String, Long> userTokens = cache.computeIfAbsent(name, (k) -> buildCache()); userTokens.remove(secret); return userTokens.size(); } @JsonCreator  TokenCache(@JsonProperty(value = "policy", required = true) ExpirationPolicy policy,
                      @JsonProperty(value = "timeout", required = true) @Time(TimeUnit.SECONDS) int timeout,
                      @JsonProperty("outputPath") Path outputPath); boolean get(@Nullable String name, @Nullable String secret); void put(@Nonnull String name, @Nonnull String secret); int remove(@Nonnull String name, @Nonnull String secret); void evict(@Nonnull String name); @Override void close(); }
TokenCache implements Closeable { public int remove(@Nonnull String name, @Nonnull String secret) { ConcurrentHashMap<String, Long> userTokens = cache.computeIfAbsent(name, (k) -> buildCache()); userTokens.remove(secret); return userTokens.size(); } @JsonCreator  TokenCache(@JsonProperty(value = "policy", required = true) ExpirationPolicy policy,
                      @JsonProperty(value = "timeout", required = true) @Time(TimeUnit.SECONDS) int timeout,
                      @JsonProperty("outputPath") Path outputPath); boolean get(@Nullable String name, @Nullable String secret); void put(@Nonnull String name, @Nonnull String secret); int remove(@Nonnull String name, @Nonnull String secret); void evict(@Nonnull String name); @Override void close(); @Nonnull
    final ExpirationPolicy policy; final int timeout; }