Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
ScalaCache
Chris Birchall
#m3dev Tech Talk
2014/04/23
ScalaCache
Simple facade for popular cache systems
● Google Guava
● Ehcache
● Memcached
● Redis
● … easy to add your own
Example
Full source here
https://gist.github.com/cb372/11200131
The Java way:
● Unavoidable repetition
● Weak against refactoring
KILLER
FEATURE! Method memoization
public int foo(int a,...
The Spring way:
● AOP, Proxy objects = runtime magic
● Some restrictions, e.g. cannot call method
from the same class
KILL...
The ScalaCache way:
● Macros = compile-time magic!
● Auto-generates cache key, e.g. “com.
bar.Baz.foo(123, 456, xyz)”
KILL...
Aside: Quasiquotes
Macros got a lot easier to write in 2.11
e.g.
Before
After
Roadmap
Investigating new features for ScalaCache
● Async support
● Versioning, a.k.a. key-based expiration
● Customizable...
Try it!
scalaVersion := 2.11.0
resolvers += “Sonatype snapshots” at
“https://oss.sonatype.org/content/repositories/snapsho...
Upcoming SlideShare
Loading in …5
×
Upcoming SlideShare
多分モダンなWebアプリ開発
Next
Download to read offline and view in fullscreen.

Share

ScalaCache: simple caching in Scala

Download to read offline

https://github.com/cb372/scalacache

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

ScalaCache: simple caching in Scala

  1. 1. ScalaCache Chris Birchall #m3dev Tech Talk 2014/04/23
  2. 2. ScalaCache Simple facade for popular cache systems ● Google Guava ● Ehcache ● Memcached ● Redis ● … easy to add your own
  3. 3. Example Full source here https://gist.github.com/cb372/11200131
  4. 4. The Java way: ● Unavoidable repetition ● Weak against refactoring KILLER FEATURE! Method memoization public int foo(int a, int b, String c) { String key = toKey(“foo”, a, b, c); return withCache(key, () -> { // … do stuff … return x; }); }
  5. 5. The Spring way: ● AOP, Proxy objects = runtime magic ● Some restrictions, e.g. cannot call method from the same class KILLER FEATURE! Method memoization @Cacheable(“cacheName”) public int foo(int a, int b, String c) { // … do stuff ... return x; }
  6. 6. The ScalaCache way: ● Macros = compile-time magic! ● Auto-generates cache key, e.g. “com. bar.Baz.foo(123, 456, xyz)” KILLER FEATURE! Method memoization def foo(a: Int, b: Int, c: String): Int = memoize { // … do stuff … x }
  7. 7. Aside: Quasiquotes Macros got a lot easier to write in 2.11 e.g. Before After
  8. 8. Roadmap Investigating new features for ScalaCache ● Async support ● Versioning, a.k.a. key-based expiration ● Customizable serialization ● API improvements ● Integration with browser caching à la Play Cache
  9. 9. Try it! scalaVersion := 2.11.0 resolvers += “Sonatype snapshots” at “https://oss.sonatype.org/content/repositories/snapshots/” libraryDependencies += “com.github.cb372” %% “scalacache” % “0.3.0-SNAPSHOT” More info at https://github.com/cb372/scalacache
  • leelakrsna

    Aug. 14, 2018

https://github.com/cb372/scalacache

Views

Total views

6,765

On Slideshare

0

From embeds

0

Number of embeds

1,943

Actions

Downloads

10

Shares

0

Comments

0

Likes

1

×