envoyproxy / java-control-plane

Java implementation of an Envoy gRPC control plane
Apache License 2.0
293 stars 136 forks source link

cache: add SnapshotCache#clearSnapshot #52

Closed snowp closed 6 years ago

snowp commented 6 years ago

Adds a method to SnapshotCache that allows clearing out a Snapshot and associated metadata. This allows clearing out cache entries that are known to be no longer needed as a way to keep the size of the cache in check.

Signed-off-by: Snow Pettersen snowp@squareup.com

codecov-io commented 6 years ago

Codecov Report

Merging #52 into master will increase coverage by 0.1%. The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master      #52     +/-   ##
===========================================
+ Coverage     95.26%   95.36%   +0.1%     
- Complexity      101      104      +3     
===========================================
  Files            11       11             
  Lines           401      410      +9     
  Branches         32       33      +1     
===========================================
+ Hits            382      391      +9     
  Misses           13       13             
  Partials          6        6
Impacted Files Coverage Δ Complexity Δ
.../io/envoyproxy/controlplane/cache/SimpleCache.java 100% <100%> (ø) 25 <3> (+3) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update ea0a647...c61b5ac. Read the comment docs.

snowp commented 6 years ago

The main idea is to allow users of java-control-plane to implement a cache eviction mechanism on their own.

Separately I want to use this to implement a simple cache eviction mechanism in java-control-plane itself which clears out snapshots for groups that have no open streams associated with them (this is basically upstreaming the cache eviction strategy we use for other snapshot generating resources).