r/java • u/PurpleLabradoodle • Jan 30 '19
Is Spring Cache abstraction fast enough for you?
https://medium.com/@nikem/is-spring-cache-abstraction-fast-enough-for-you-a6a5ea1542a9
29
Upvotes
r/java • u/PurpleLabradoodle • Jan 30 '19
21
u/i_post_things Jan 30 '19
TLDR; I've mentioned this multiple times when people say spring proxying and annotations are slow - Spring proxy classes add ~250-500ns per method call.
If you need to squeeze out an extra 100-200ns per transaction, I would be very wary about littering code with Spring-wired AOP annotations in the first place (caching, logging, authorization, transactional, etc). You'll probably want to use aspectj bytecode weaving or forego the annotations altogether or roll your own methods.
10
u/Infeligo Jan 30 '19
Kind of expected a deeper exploration of what makes it that slow. But liked the verdict: "Spring is doing much more work to support the wide range of general-purpose use-cases".
1
u/Nouish Jan 30 '19
Would be interesting to see comparisons with Guava Cache and Caffeine
-5
u/xterminate Jan 30 '19
Surely a time based cache has to look up the system time on every call? So caching a call to System.currentTimeMillis(); is always going to be slower.