I do not understand the question. Something is creating the object (a function or a constructor, which is also a function).
myobject=MyObject() You can only reference the object after it has been created or after is has been extracted from cache. This means the constructor of the object must be called the first time but not the second time. myobject = get_me_the_object_from_cache_or_make_one_using(MyObject()) In web2py this is translated as myobject = cache.ram('myobject',lambda: MyObject(), 10**10) If you already have the object you want to cache you can do this: if I already_have_the object_I_want_to_cache: cache.ram('myobject',lambda:myobject,0) else: # get me the object myobject = cache.ram('myobject',lambda: None,10**10) Since web2py 1.65.4 you can use None instead of 10**10 and None means: never expires. 0 means expires now. On Jul 16, 11:29 am, klarson <kelar...@gmail.com> wrote: > I understand that but I was wondering if there was a way to just cache > the object without having to call a function, i.e. a way to cache > large objects instead of storing them in session or pickling. > > For a little background, I'm grafting large trees together. The user > would search and view trees to copy what they need to a clipboard and > then graft into the super tree later. Since I have already created > the trees when searching, I want to cache them. When I go back to the > super tree I can do the paste without recreating that copied tree. > > I think I can do what I want by just caching the method so I was just > wondering if I can, or even should, try to cache the object directly. > > Thanks! > Krista > > On Jul 10, 3:09 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > You alwayscachethe object returned by the function. The function can > > be a dummy that returns the object you want tocache. > > > On Jul 10, 1:30 pm, krista <klarso...@msn.com> wrote: > > > > Is there a way to justcachethe object and not the function? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---