Yes, it's per app.

One important gotcha is how time_expire works. It does not mean 'keep
results for X seconds'. It means 'fetch if older than X seconds'. A
very important difference.

x = cache.ram('x', lambda: 'a', 5)
time.sleep(10)
x = cache.ram('x', lambda: 'b', 60)

x is 'a' at the end !

On Mar 26, 6:43 am, Iceberg <iceb...@21cn.com> wrote:
> Shame on me~~~ for my stupid typo. Actually I did exactly same test as
> Petrov did, on my local machine, before my last post. Yes, cache
> object looks NOT unique for each session. Thanks Petrov. *^_^*
>
> Still, I am not sure whether the cache object is unique for each
> application. It seems it is unique according to test. I still need
> some confirmation.
>
> On Mar26, 1:07pm, Vidul Petrov <vidul.r...@gmail.com> wrote:
>
> > Hi Iceberg,
>
> > From what I saw, the cache object is not unique, it's that the samle
> > has "time_expire=5" and most probably you've loaded the page on the
> > 2nd browser for more than 5 seconds.
> > In addition a test made on two boxes with something like:
>
> > def mycache():
> >       import time
> >       t=cache.ram('time',lambda:time.ctime(),time_expire=100)
> >       return dict(time=t,link=A('click me',_href=URL(r=request)))
>
> > proves that the same cache object is returned.
>
> > But I am just guessing.
>
> > On Mar 26, 6:02 am, Iceberg <iceb...@21cn.com> wrote:
>
> > > On Mar26, 2:56am, Mark Larsen <larsen...@gmail.com> wrote:
>
> > > > Also is the cache object unique for each session?  Does Web2py have any
> > > > concept of a shared cache for all sessons?
>
> > > I share what I just test, and what I do not know, and hope some expert
> > > can confirm them.
>
> > > Cache object seems unique for each session. I just open two different
> > > browser (Chrome and IE, and hence two sessions) to visit same cache
> > > sample (http://www.web2py.com/examples/cache_examples/cache_in_ram),
> > > and see cache effect can work on two sessions.
>
> > > But I am still not sure, is the cache object unique for each
> > > application, or are they share same namespace when in one web2py
> > > process? In other words, do I need to use cache in this way in my
> > > every application?
> > >    cache.ram('%s:key'%request.application, lambda: foo(),
> > > time_expire=xxxx)
>
> > > By the way, if the cache object is unique for each application, what
> > > is the proper way to share info between application if needed?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to