On Oct 16, 10:07 am, Florent <[email protected]> wrote:
> I saw that sequel has a caching feature but it's using memcache-
> client.
> I prefer the memcached version (http://github.com/fauna/memcached)
> that is know to be a lot faster. Problem is that memcached API is a
> bit different of memcache-client API.

In that case, I recommend writing a proxy object that translates the
former API to the latter, and use that with the existing plugin, or
copy the existing plugin and modifying it to use the other API.

> Can I create a new plugin based on caching.rb that supports
> memcached ?

Yes.

> Another point slightly different but in the same topic: I have another
> use case that I would like to cache sequel model but not when it
> misses the cache (like the actual plugin) but when updating/saving
> only. I think it's more on application level than in a plugin to be
> implemented.

Modifying a copy of the plugin is probably the route you want to take,
then.

> I have an application that inserts/updates a lot and if I clear the
> cache each time it inserts/updates, there will be to many cache miss
> when finding to be useful.

That makes sense.  The caching plugin was designed with a mostly read
mindset, which is where you benefit the most from caching.

> I've spotted that I can only cache sequel model _before_ save or
> update call, otherwise it can't be cached: "TypeError: can't dump hash
> with default proc"

Hmm, weird.  Can you send a backtrace for this error?

> It's not likely a problem to cache the model before save/update
> (values are the same), but when you cache a new model (not created in
> database yet), you get it back from the cache and it's still
> considered "new" from the model point of view.

That's one of the reasons the current plugin works the way it does.

> One solution is to cache only model.values and when I get back from
> cache, I initialize model with values from the cache, but I would like
> to know what is the difference in the model before and after a save/
> update call (where do these proc come from) ?

If you only want to cache model.values, just call Model.load with the
hash when you retrieve it from the cache.

Honestly, I'm not sure why you are getting that TypeError, which is
why I'd like to look at the backtrace.

Jeremy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to