On Oct 19, 6:30 am, Florent <[email protected]> wrote:
> Actual plugin works this way:
> Find request: lookup in memcached ? if present give cached value, if
> not give DB value and store it in the cache
> Insert/Update request: update in DB and clear the cache
>
> I think that updating the cache in insert/update requests is as
> expensive as clearing the cache, and would suit both needs (heavy
> reads and heavy inserts/updates use cases). or maybe put an option in
> the plugin to choose between both behaviour (clear the cache on update
> or set the cache on update)

My guess is that the plugin currently works the way it does because of
the previous issues in marshalling saved model objects (hint, see
below).  I think it might be better to keep the current behavior as it
is more memory friendly than caching after save.

> > > 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?
>
> I have tested with two memcached clients to be sure it was not my
> memcached client fault.
> here is the two related gists:http://gist.github.com/213348
>
> I think it's normal that memcached can't marshal proc in a ruby
> object, but what I don't understand is where do these proc come from
> between before and after the save call.

That error comes from the fact that Sequel::Model::Errors is a
subclass of Hash that uses a default proc.  It can be reprogrammed to
not use a default proc, but it still fails when marshalling @this,
which is a dataset that has a singleton class (as all model datasets
and many regular datasets do).  I just pushed a commit that fixes
these issues, allowing you to marshal saved model objects (http://
github.com/jeremyevans/sequel/commit/
c12d3fa5b0e51261dafe95383ad8a36583297d35).

> > > 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.
>
> In my code, I need to know if a sequel model is new or not, so I don't
> cache it when it's new (but that makes the cache miss for the next
> find request). it's not very convenient but it works.

Well, give the current master branch a shot and let me know how it
goes.

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