I don't understand something... I have this : ```python def set_dict_test(): if 'dict123' not in globals(): print 'dict123 not in globals : %s' % str('dict123' not in globals()) global dict123 dict123 = cache.ram('dict123', lambda: {1: 1, 2: 2, 3: 3}, time_expire=None) # dict123 = {1: 1, 2: 2, 3: 3} else: print 'no dict creation' print dict123
set_dict_test() # dict123 = cache.ram('dict123', lambda: {1: 1, 2: 2, 3: 3}, time_expire=None) print 'AFTER function call... dict123 in globals : %s' % str('dict123' in globals()) print dict123 ``` What I don't understand is why each time set_dict_test() is call dict123 is never in globals(). If I don't use cache.ram dict123 is in globals() and function return the else: part of the function... It the same for cache.redis() Richard On Thu, Jan 14, 2016 at 3:47 PM, Richard Vézina <ml.richard.vez...@gmail.com > wrote: > Forget about last message I was making a mistake in my print statments > > On Thu, Jan 14, 2016 at 3:40 PM, Richard Vézina < > ml.richard.vez...@gmail.com> wrote: > >> There is something I don't understand... I put a couple of print >> statments to see if my cached vars was in globals() and I discover that my >> var was never there... >> >> I am lost completly... If it pass throught my "if" my dict will be >> recreated each request... >> >> :( >> >> Richard >> >> On Thu, Jan 14, 2016 at 12:13 PM, Richard Vézina < >> ml.richard.vez...@gmail.com> wrote: >> >>> Yes, this may be an option (update whole dict in Redis)... Mean time I >>> get rid of them, if I can succeed in that... >>> >>> :) >>> >>> Thanks Anthony. >>> >>> Richard >>> >>> On Thu, Jan 14, 2016 at 12:06 PM, Anthony <abasta...@gmail.com> wrote: >>> >>>> On Thursday, January 14, 2016 at 11:12:12 AM UTC-5, Richard wrote: >>>>> >>>>> This is true for any other cache except cache.ram right? >>>>> >>>> >>>> Right. cache.ram works because it doesn't have to pickle a Python >>>> object and put it into external storage (and therefore create a fresh copy >>>> of the stored object via unpickling at retrieval time). Rather, it simply >>>> stores a pointer to the existing Python object within the current Python >>>> process. Of course, this limits cache.ram to a single process, so if your >>>> app is being served by multiple processes, each will have its own version >>>> of cache.ram. >>>> >>>> >>>>> If so, there is no gain with cache.redis the way I use it... >>>>> >>>> >>>> Well, the gain with Redis is that it will actually work, though you >>>> will have to adjust your code to save the whole dictionary back to the >>>> cache upon update. >>>> >>>> >>>>> @Anthony, are you sure about the issue with uwsgi/nginx and cache.ram >>>>> dict update? >>>>> >>>> >>>> I think so. You might try configuring uwsgi to run a single process >>>> with multiple threads instead of using multiple processes. Not sure how >>>> that will impact performance. >>>> >>>> >>>>> I guess, I should start to look at how to get rid of these global dict >>>>> while not degrading system performance. There surely place where I use >>>>> these global vars that wouldn't suffer from a little query to the backend, >>>>> but for grid where the performance was the greatest or simplifying code >>>>> was >>>>> acheive with those it will be difficult to stop using them... >>>>> >>>> >>>> Is it really a problem to write the whole dictionary to Redis? How >>>> often are updates happening? >>>> >>>> Anthony >>>> >>>> -- >>>> 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. >>>> >>> >>> >> > -- 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.