mumoshu/play2-memcached

delete the object when the `set` method accepts null value.

gakuzzzz opened this issue · 6 comments

Cache API of Play2.0 has no a method to remove object.

Seemingly, What the ‘set‘ method remove when it accepts null somehow is expected.
https://groups.google.com/forum/?fromgroups#!topicsearchin/play-framework/2.0$242420cache$242420remove/play-framework/pHb1Dq1wiic

However, MemcachedPlugin seems not to act such.

Would you make MemcachedPlugin possible to remove a object?

Oh, Cache API of Play2.1 will have a method to remove a object.
playframework/playframework@dd293a5

MemcachedPlugin is trying to be compliant with EhCachePlugin - the default cache implementation in Play 2.0.

Currently, EhCachePlugin does not remove the previously stored value on putting null;
instead, it stores a 'null' value so that we get Some(null) from Cache#get(key).
Check specs I wrote to confirm current behaviors of the Ehcache impl.

Later, in the Play 2.1 version of MemcachedPlugin, I will implement CacheAPI#remove.

For now, I guess that providing our own way to remove stored values via new MemcachedPlugin#remove(key) is nice.
How do you think of this?

I have ended up to thinking that adding remove(key) to MemcachedPlugin.api insted of MemcachedPlugin itself is much better.
play.api.Play.current.plugin[MemcachedPlugin].get.remove is indeed not standard in Play 2.1, but play.api.Play.current.plugin[MemcachedPlugin].get.api.remove is.

I'm sorry. I had not confirm the EhCache Plugin.

I think that your idea is good!

I have added the remove method to MemcachedPlugin.api.