-
Notifications
You must be signed in to change notification settings - Fork 52
fix: flagd caching #581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Kavindu-Dodan
merged 4 commits into
open-feature:main
from
Kavindu-Dodan:fix/cache-type-resolving
Dec 11, 2023
Merged
fix: flagd caching #581
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 21 additions & 20 deletions
41
...lagd/src/main/java/dev/openfeature/contrib/providers/flagd/resolver/grpc/cache/Cache.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
...c/main/java/dev/openfeature/contrib/providers/flagd/resolver/grpc/cache/CacheFactory.java
This file was deleted.
Oops, something went wrong.
16 changes: 6 additions & 10 deletions
16
.../src/main/java/dev/openfeature/contrib/providers/flagd/resolver/grpc/cache/CacheType.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,18 @@ | ||
package dev.openfeature.contrib.providers.flagd.resolver.grpc.cache; | ||
|
||
import static dev.openfeature.contrib.providers.flagd.Config.LRU_CACHE; | ||
import lombok.Getter; | ||
|
||
/** | ||
* Defines which type of cache to use. | ||
*/ | ||
@Getter | ||
public enum CacheType { | ||
DISABLED("disabled"), | ||
LRU(LRU_CACHE); | ||
LRU("lru"); | ||
|
||
private final String type; | ||
private final String value; | ||
|
||
CacheType(String type) { | ||
this.type = type; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return this.type; | ||
CacheType(String value) { | ||
this.value = value; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
.../src/test/java/dev/openfeature/contrib/providers/flagd/resolver/grpc/cache/CacheTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package dev.openfeature.contrib.providers.flagd.resolver.grpc.cache; | ||
|
||
import dev.openfeature.sdk.ProviderEvaluation; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static dev.openfeature.contrib.providers.flagd.resolver.grpc.cache.CacheType.DISABLED; | ||
import static dev.openfeature.contrib.providers.flagd.resolver.grpc.cache.CacheType.LRU; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
class CacheTest { | ||
|
||
@Test | ||
void cacheTypeTest() { | ||
// given | ||
final Cache disabled = new Cache(DISABLED.getValue(), 0); | ||
final Cache lru = new Cache(LRU.getValue(), 10); | ||
final Cache undefined = new Cache("invalid", 10); | ||
|
||
// then | ||
assertTrue(lru.getEnabled()); | ||
assertFalse(disabled.getEnabled()); | ||
assertFalse(undefined.getEnabled()); | ||
} | ||
|
||
|
||
@Test | ||
void lruOperationValidation() { | ||
// given | ||
final Cache lru = new Cache(LRU.getValue(), 1); | ||
|
||
// when | ||
final ProviderEvaluation<Object> evaluation = ProviderEvaluation.builder() | ||
.value("value") | ||
.variant("one") | ||
.build(); | ||
lru.put("key", evaluation); | ||
|
||
// then | ||
assertEquals(evaluation, lru.get("key")); | ||
|
||
// when | ||
lru.clear(); | ||
|
||
// then | ||
assertNull(lru.get("key")); | ||
} | ||
} |
Submodule test-harness
updated
from 0710b7 to 5b428c
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.