-
Notifications
You must be signed in to change notification settings - Fork 9
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
Adding a caching layer #15
base: master
Are you sure you want to change the base?
Conversation
Two general comments if you don't mind, as you tagged me in the original issue:
More specifically, if you bring in caffeine and a protocol, I'd split them up in two namespaces and make Caffeine a managed dependency, such that pulling in Porsas won't pull it in by default. The implementation will be in another namespace which will be required by In the caffeine implementation namespace you can then I'd also be interested in seeing an async loading cache, especially combined with the async vertx client. |
Sure thing, thanks for the review! :)
As I could see, it's a very lightweight wrapper, not sure it's that big of an overhead. Although it's only used in one ns and not much of a code so I'm fine using just
I used
This is a good idea, originally I was thinking just to leave one of the implementations in, so that would be used by default.
Could you elaborate on this pls? Not sure that can be used here, to calculate the cached value we need to have the |
And if tomorrow there's a bug in Caffeine and you need to wait for Cloffeine's maintainers to update a transitive dependency? Using Caffeine directly means less dependencies, less opinions, and less moving pieces.
You might be surprised if you run a survey across all Clojure programmers. I work with about 200 of them who don't use it.
Git is not Github, tomorrow we might all end up using another platform. When it comes right down to it, even good formatting changes, combined with logical changes, are noise. Some of them are not just whitespace changes. There's also an underlying assumption that patch readers and reviewers work only via Github's interface. Another thing to remember is that diffs are for the future, too. Let's assume there's a bug introduced by a commit. What properties should that commit have to make it easier to review? A preliminary formatting PR is perfectly legit if you intend to change formatting, but I can only share my experience in that some developers would reject such patches almost on principle.
In the end, I'm not the code owner, these are mostly conclusions I had to learn the hard way.
Thinking of returning a CompletionStage via loading cache and completing the computation |
Totally valid points, let me try to rework that part.
You are right, I'm surprised 😄
Thanks for sharing your experience, I'm quite new to contributing to open source, I'll consider these in the future.
hmm, let me try that, I don't have lots of experience with |
@bsless @ikitommi I cleaned up the PR a little during the weekend and also separated the caching implementations into their own ns as @bsless suggested. |
Fixes #7
I've added a default implementation for the
Cache
protocol which usescore.cache
. Users could implement their own using a different caching lib and pass it in.Ran the load tests, this implementation added ~200ns to the original measurements using
basic-cache
which is basically a fancy map, usinglru-cache
andlu-cache
are doubled the measured times. The existing perf-test won't really show the advantages of the more advanced caches as it uses only one query so the eviction is not kicking in. By default,basic-cache
is created for now, although that's not bounded so I guess the memory leak problem could still exist.Added
caffeine
based solution too, with the default cache settings it seems much faster than thecore.cache
-based impl.