This one:

A. Does the cached object get updated:

The cached object is updated immediately because it's the same object. 
Cache ram does not clone it. Notice that the behaviour will be different if 
you're using cache disk.

Do know that doing this is a very bad idea, as you will run into all sorts 
of thread safety problems. You should consider cached values immutable if 
you don't want to worry about safety yourself.


And finally, if I wish to force a changed value of some_object to be saved 
to the cache, am I correct that I should then call:
some_object.arg3 = 1111
some_object = cache.ram(self.id_attribute, lambda self, time=0)


This will force the change, but, again, if it's the same object the change 
will already be there.

> Does this mean that the next time someone instantiates an object of class 
"SomeClass" with the same arg1 value but a different time_expire value, the 
cached object will be overwritten?

It will be overwritten if the cached value has a timestamp that is expired 
with the given time_expire value. 
  


I think that maybe your problem is that you're not understanding what the 
cache is actually saving in your example. When you put an object in cache 
ram, what's actually in the cache is a reference to the object. So if you 
have a reference to that same object somewhere else and you modify it, 
you're actually modifying the same object that cache is referencing.

Cache disk is different, because cache disk pickles your object and when 
you ask it for a value it unpickles it, so each time you will get a new 
object albeit with the same attributes.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to