mumoshu / play2-memcached

A memcached plugin for Play 2.x
Other
161 stars 66 forks source link

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

Closed gakuzzzz closed 12 years ago

gakuzzzz commented 12 years ago

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?

gakuzzzz commented 12 years ago

Oh, Cache API of Play2.1 will have a method to remove a object. https://github.com/playframework/Play20/commit/dd293a5f170f4ef32ff84c6c5e856dd11fafe617

mumoshu commented 12 years ago

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.

mumoshu commented 12 years ago

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?

mumoshu commented 12 years ago

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.

gakuzzzz commented 12 years ago

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

I think that your idea is good!

mumoshu commented 12 years ago

I have added the remove method to MemcachedPlugin.api.