I am running Java Play framework version v2.6.1 and using Ebean for persistence. My intention is to get bean caching going using play2-memcached plugin.
What have I done so far?
- installed
memcached
on localhost and enabled verbose logging. - replaced
ehcache
dependency withcacheApi
inlibraryDependencies
inbuild.sbt
(this, I assume, should remove Ehcache completely). - added
"com.github.mumoshu" %% "play2-memcached-play26" % "0.9.0",
tolibraryDependencies
inbuild.sbt
- added
"Spy Repository" at "http://files.couchbase.com/maven2",
toresolvers
inbuild.sbt
- added following entries to application conf:
play.modules.disabled += "play.api.cache.ehcache.EhCacheModule"
play.modules.enabled+="com.github.mumoshu.play2.memcached.MemcachedModule"
play.cache.defaultCache=default
play.cache.bindCaches=["db-cache", "user-cache", "session-cache"]
memcached.host="127.0.0.1:11211"
- took my entity and made it implement
Serializable
, also added@com.avaje.ebean.annotation.Cache
annotation. - enabled SQL logging
What works?
- loading entity with
Entity.find.byId(id)
results SQLSELECT
. Loading it again with different request results no SQL statements. - opening browser to localhost:11211 shows errors in syslog -- this is to make sure memcached is running and I can see requests appearing
- making memory dump I can see that cache related classes from
com.github.mumoshu
are loaded.
What doesn't work?
- I expect cached objects to be sent to memcached (on read and/or update). This is not happening - there are no memcached logs related to this. Neither there are any connections to port 11211 if I run
netstat -na | grep 11211
.
Is there anything I'm missing?
@CacheStrategy
is renamed to@Cache
. github.com/ebean-orm/ebean/issues/684 – Unbound