-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Caching pattern: Cache-Aside #495
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
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6ed842e
Caching pattern: Refactor shutdown hook to use method reference
christofferh 865f788
Caching pattern: Refactor LRU cache to avoid NPE and unnecessary cach…
christofferh e3355d7
Caching pattern: Style fix for null check
christofferh b31edda
Caching pattern: Implementation of Cache-Aside pattern
christofferh f114b5b
Caching pattern: Documentation and diagram
christofferh 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,106 +1,90 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<class-diagram version="1.1.8" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true" | ||
realizations="true" associations="true" dependencies="false" nesting-relationships="true"> | ||
<class id="1" language="java" name="main.java.com.wssia.caching.App" project="CachingPatterns" | ||
file="/CachingPatterns/src/main/java/com/wssia/caching/App.java" binary="false" corner="BOTTOM_RIGHT"> | ||
<position height="-1" width="-1" x="249" y="150"/> | ||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" | ||
sort-features="false" accessors="true" visibility="true"> | ||
<attributes public="true" package="true" protected="true" private="true" static="true"/> | ||
<operations public="true" package="true" protected="true" private="true" static="true"/> | ||
</display> | ||
<class-diagram version="1.1.11" icons="true" automaticImage="PNG" always-add-relationships="false" | ||
generalizations="true" realizations="true" associations="true" dependencies="false" nesting-relationships="true" | ||
router="FAN"> | ||
<class id="1" language="java" name="com.iluwatar.caching.CacheStore" project="caching" | ||
file="/caching/src/main/java/com/iluwatar/caching/CacheStore.java" binary="false" corner="BOTTOM_RIGHT"> | ||
<position height="-1" width="-1" x="322" y="444"/> | ||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" | ||
sort-features="false" accessors="true" visibility="true"> | ||
<attributes public="true" package="true" protected="true" private="true" static="true"/> | ||
<operations public="true" package="true" protected="true" private="true" static="true"/> | ||
</display> | ||
</class> | ||
<class id="2" language="java" name="com.iluwatar.caching.LruCache" project="caching" | ||
file="/caching/src/main/java/com/iluwatar/caching/LruCache.java" binary="false" corner="BOTTOM_RIGHT"> | ||
<position height="-1" width="-1" x="700" y="446"/> | ||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" | ||
sort-features="false" accessors="true" visibility="true"> | ||
<attributes public="true" package="true" protected="true" private="true" static="true"/> | ||
<operations public="true" package="true" protected="true" private="true" static="true"/> | ||
</display> | ||
</class> | ||
<enumeration id="3" language="java" name="com.iluwatar.caching.CachingPolicy" project="caching" | ||
file="/caching/src/main/java/com/iluwatar/caching/CachingPolicy.java" binary="false" corner="BOTTOM_RIGHT"> | ||
<position height="-1" width="-1" x="943" y="122"/> | ||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" | ||
sort-features="false" accessors="true" visibility="true"> | ||
<attributes public="true" package="true" protected="true" private="true" static="true"/> | ||
<operations public="true" package="true" protected="true" private="true" static="true"/> | ||
</display> | ||
</enumeration> | ||
<class id="4" language="java" name="com.iluwatar.caching.DbManager" project="caching" | ||
file="/caching/src/main/java/com/iluwatar/caching/DbManager.java" binary="false" corner="BOTTOM_RIGHT"> | ||
<position height="-1" width="-1" x="1011" y="426"/> | ||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" | ||
sort-features="false" accessors="true" visibility="true"> | ||
<attributes public="true" package="true" protected="true" private="true" static="true"/> | ||
<operations public="true" package="true" protected="true" private="true" static="true"/> | ||
</display> | ||
</class> | ||
<class id="5" language="java" name="com.iluwatar.caching.App" project="caching" | ||
file="/caching/src/main/java/com/iluwatar/caching/App.java" binary="false" corner="BOTTOM_RIGHT"> | ||
<position height="-1" width="-1" x="304" y="95"/> | ||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" | ||
sort-features="false" accessors="true" visibility="true"> | ||
<attributes public="true" package="true" protected="true" private="true" static="true"/> | ||
<operations public="true" package="true" protected="true" private="true" static="true"/> | ||
</display> | ||
</class> | ||
<class id="6" language="java" name="com.iluwatar.caching.AppManager" project="caching" | ||
file="/caching/src/main/java/com/iluwatar/caching/AppManager.java" binary="false" corner="BOTTOM_RIGHT"> | ||
<position height="-1" width="-1" x="604" y="122"/> | ||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" | ||
sort-features="false" accessors="true" visibility="true"> | ||
<attributes public="true" package="true" protected="true" private="true" static="true"/> | ||
<operations public="true" package="true" protected="true" private="true" static="true"/> | ||
</display> | ||
</class> | ||
<class id="7" language="java" name="com.iluwatar.caching.UserAccount" project="caching" | ||
file="/caching/src/main/java/com/iluwatar/caching/UserAccount.java" binary="false" corner="BOTTOM_RIGHT"> | ||
<position height="-1" width="-1" x="1161" y="139"/> | ||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" | ||
sort-features="false" accessors="true" visibility="true"> | ||
<attributes public="true" package="true" protected="true" private="true" static="true"/> | ||
<operations public="true" package="true" protected="true" private="true" static="true"/> | ||
</display> | ||
</class> | ||
<class id="2" language="java" name="main.java.com.wssia.caching.AppManager" project="CachingPatterns" | ||
file="/CachingPatterns/src/main/java/com/wssia/caching/AppManager.java" binary="false" corner="BOTTOM_RIGHT"> | ||
<position height="-1" width="-1" x="502" y="163"/> | ||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" | ||
sort-features="false" accessors="true" visibility="true"> | ||
<attributes public="true" package="true" protected="true" private="true" static="true"/> | ||
<operations public="true" package="true" protected="true" private="true" static="true"/> | ||
</display> | ||
</class> | ||
<class id="3" language="java" name="main.java.com.wssia.caching.CacheStore" project="CachingPatterns" | ||
file="/CachingPatterns/src/main/java/com/wssia/caching/CacheStore.java" binary="false" corner="BOTTOM_RIGHT"> | ||
<position height="-1" width="-1" x="537" y="436"/> | ||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" | ||
sort-features="false" accessors="true" visibility="true"> | ||
<attributes public="true" package="true" protected="true" private="true" static="true"/> | ||
<operations public="true" package="true" protected="true" private="true" static="true"/> | ||
</display> | ||
</class> | ||
<enumeration id="4" language="java" name="main.java.com.wssia.caching.CachingPolicy" project="CachingPatterns" | ||
file="/CachingPatterns/src/main/java/com/wssia/caching/CachingPolicy.java" binary="false" corner="BOTTOM_RIGHT"> | ||
<position height="-1" width="-1" x="789" y="162"/> | ||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" | ||
sort-features="false" accessors="true" visibility="true"> | ||
<attributes public="true" package="true" protected="true" private="true" static="true"/> | ||
<operations public="true" package="true" protected="true" private="true" static="true"/> | ||
</display> | ||
</enumeration> | ||
<class id="5" language="java" name="main.java.com.wssia.caching.DBManager" project="CachingPatterns" | ||
file="/CachingPatterns/src/main/java/com/wssia/caching/DBManager.java" binary="false" corner="BOTTOM_RIGHT"> | ||
<position height="-1" width="-1" x="1137" y="134"/> | ||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" | ||
sort-features="false" accessors="true" visibility="true"> | ||
<attributes public="true" package="true" protected="true" private="true" static="true"/> | ||
<operations public="true" package="true" protected="true" private="true" static="true"/> | ||
</display> | ||
</class> | ||
<class id="6" language="java" name="main.java.com.wssia.caching.LRUCache" project="CachingPatterns" | ||
file="/CachingPatterns/src/main/java/com/wssia/caching/LRUCache.java" binary="false" corner="BOTTOM_RIGHT"> | ||
<position height="-1" width="-1" x="884" y="435"/> | ||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" | ||
sort-features="false" accessors="true" visibility="true"> | ||
<attributes public="true" package="true" protected="true" private="true" static="true"/> | ||
<operations public="true" package="true" protected="true" private="true" static="true"/> | ||
</display> | ||
</class> | ||
<class id="7" language="java" name="main.java.com.wssia.caching.UserAccount" project="CachingPatterns" | ||
file="/CachingPatterns/src/main/java/com/wssia/caching/UserAccount.java" binary="false" corner="BOTTOM_RIGHT"> | ||
<position height="-1" width="-1" x="1140" y="405"/> | ||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" | ||
sort-features="false" accessors="true" visibility="true"> | ||
<attributes public="true" package="true" protected="true" private="true" static="true"/> | ||
<operations public="true" package="true" protected="true" private="true" static="true"/> | ||
</display> | ||
</class> | ||
<class id="8" language="java" name="test.java.com.wssia.caching.AppTest" project="CachingPatterns" | ||
file="/CachingPatterns/src/test/java/com/wssia/caching/AppTest.java" binary="false" corner="BOTTOM_RIGHT"> | ||
<position height="-1" width="-1" x="251" y="374"/> | ||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" | ||
sort-features="false" accessors="true" visibility="true"> | ||
<attributes public="true" package="true" protected="true" private="true" static="true"/> | ||
<operations public="true" package="true" protected="true" private="true" static="true"/> | ||
</display> | ||
</class> | ||
<association id="9"> | ||
<end type="SOURCE" refId="2" navigable="false"> | ||
<attribute id="10" name="cachingPolicy"/> | ||
<multiplicity id="11" minimum="0" maximum="1"/> | ||
</end> | ||
<end type="TARGET" refId="4" navigable="true"/> | ||
<display labels="true" multiplicity="true"/> | ||
</association> | ||
<association id="12"> | ||
<end type="SOURCE" refId="8" navigable="false"> | ||
<attribute id="13" name="app"/> | ||
<multiplicity id="14" minimum="0" maximum="1"/> | ||
</end> | ||
<end type="TARGET" refId="1" navigable="true"/> | ||
<display labels="true" multiplicity="true"/> | ||
</association> | ||
<association id="15"> | ||
<end type="SOURCE" refId="3" navigable="false"> | ||
<attribute id="16" name="cache"/> | ||
<multiplicity id="17" minimum="0" maximum="1"/> | ||
</end> | ||
<end type="TARGET" refId="6" navigable="true"/> | ||
<display labels="true" multiplicity="true"/> | ||
</association> | ||
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" | ||
sort-features="false" accessors="true" visibility="true"> | ||
<attributes public="true" package="true" protected="true" private="true" static="true"/> | ||
<operations public="true" package="true" protected="true" private="true" static="true"/> | ||
</classifier-display> | ||
<association id="8"> | ||
<end type="SOURCE" refId="1" navigable="false"> | ||
<attribute id="9" name="cache"/> | ||
<multiplicity id="10" minimum="0" maximum="1"/> | ||
</end> | ||
<end type="TARGET" refId="2" navigable="true"/> | ||
<display labels="true" multiplicity="true"/> | ||
</association> | ||
<association id="11"> | ||
<end type="SOURCE" refId="6" navigable="false"> | ||
<attribute id="12" name="cachingPolicy"/> | ||
<multiplicity id="13" minimum="0" maximum="1"/> | ||
</end> | ||
<end type="TARGET" refId="3" navigable="true"/> | ||
<display labels="true" multiplicity="true"/> | ||
</association> | ||
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" | ||
sort-features="false" accessors="true" visibility="true"> | ||
<attributes public="true" package="true" protected="true" private="true" static="true"/> | ||
<operations public="true" package="true" protected="true" private="true" static="true"/> | ||
</classifier-display> | ||
<association-display labels="true" multiplicity="true"/> | ||
</class-diagram> | ||
</class-diagram> |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason for not using logging framework like SLF4J or LOG4J Or Common logging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chinnachalam you are right, using a logging framework would give some advantages such as ability to redirect output and filter output based on logging levels. But I think we should handle this issue on a more general level since there are multiple patterns not using a logging framework at the moment. Would you raise an issue about this matter, please?