Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #100973

Re: Cannot get the value from dogpile.cache from different modules.

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Newsgroups comp.lang.python
Subject Re: Cannot get the value from dogpile.cache from different modules.
Date Tue, 29 Dec 2015 17:49:07 -0500
Organization IISS Elusive Unicorn
Lines 68
Message-ID <mailman.62.1451429362.11925.python-list@python.org> (permalink)
References <7c8df879-b03a-4323-90c5-3221dd1eced2@googlegroups.com> <e94e9346-cccd-44cb-b889-75c308921555@googlegroups.com> <mailman.55.1451409296.11925.python-list@python.org> <337dc80d-bd55-4976-a716-fc8f793a1322@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de 12kYgpQ+vI8fAIg/m9eNwAVJ8ak5tRakKSxWwcqe/GsQ==
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'static': 0.03; '"""': 0.05; 'cache': 0.05; 'exist,': 0.07; 'message-id:@4ax.com': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'type)': 0.09; 'python': 0.10; 'def': 0.13; '(string)': 0.16; 'attributes.': 0.16; 'cache:': 0.16; 'list)': 0.16; 'mailinglist': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'url:home': 0.18; 'creates': 0.18; '2015': 0.20; 'java': 0.22; 'dec': 0.23; 'import': 0.24; 'module': 0.25; 'header:X-Complaints- To:1': 0.26; 'defining': 0.27; 'subject:skip:d 10': 0.27; 'value)': 0.29; 'code': 0.30; 'skip:s 30': 0.31; 'returned': 0.32; 'class': 0.33; 'shift': 0.33; 'definition': 0.34; 'tue,': 0.34; 'list': 0.34; 'saved': 0.35; 'data.': 0.36; 'skip:m 40': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'method': 0.37; 'received:org': 0.37; 'charset:us-ascii': 0.37; 'delete': 0.38; 'data': 0.39; 'does': 0.39; 'subject:from': 0.39; 'subject:the': 0.39; 'to:addr:python.org': 0.40; 'save': 0.60; '>from': 0.76; 'subject:get': 0.81; 'subject:value': 0.84; 'dennis': 0.91
X-Injected-Via-Gmane http://gmane.org/
X-Gmane-NNTP-Posting-Host adsl-108-79-218-6.dsl.klmzmi.sbcglobal.net
X-Newsreader Forte Agent 6.00/32.1186
X-No-Archive YES
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:100973

Show key headers only | View raw


On Tue, 29 Dec 2015 09:27:02 -0800 (PST), xeon Mailinglist
<xeonmailinglist@gmail.com> declaimed the following:


>
>Here is the full class that I use to store the data.
>
>from dogpile.cache import make_region
>
>
># my_dictionary = {}
>region = make_region().configure('dogpile.cache.memory')
># arguments={"cache_dict":my_dictionary})
>class Cache:
>
>    @staticmethod
>    def save(key, value):
>        """
>        general purpose method to save data (value) in the cache
>
>        :param key (string) key of the value to be saved in cache
>        :param value (any type) the value to be saved
>        """
>        region.set(key, value)
>
>    @staticmethod
>    def get(key):
>        """
>        general purpose method to get data from the cache
>
>        :param key (string) key of the data to be fetched
>        :return value (any type) data to be returned from the cache
>        """
>        return region.get(key)
>
>
>    @staticmethod
>    def get_or_create(key):
>        """
>        General purpose method to get data from the cache. If the value does not exist, it creates a list
>
>        :param: key (string) key of the data to be fetched
>        :return value (any type) data to be returned from the cache
>        """
>        return region.get_or_create(key, list)
>
>    @staticmethod
>    def set_job_predictions(rank_list):
>        Cache.save("job_predictions", rank_list)
>
>    @staticmethod
>    def get_job_predictions():
>        return Cache.get("job_predictions")

	You are defining a Python class in which EVERY method is a static
method... Smells like Java code to me...

	Delete the class definition line, shift all the methods left and
reference them as module attributes.

import theModule

keyx = theModule.get_key("a key")

-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Cannot get the value from dogpile.cache from different modules. xeon Mailinglist <xeonmailinglist@gmail.com> - 2015-12-29 03:15 -0800
  Re: Cannot get the value from dogpile.cache from different modules. xeon Mailinglist <xeonmailinglist@gmail.com> - 2015-12-29 07:20 -0800
    Re: Cannot get the value from dogpile.cache from different modules. Peter Otten <__peter__@web.de> - 2015-12-29 17:17 +0100
      Re: Cannot get the value from dogpile.cache from different modules. xeon Mailinglist <xeonmailinglist@gmail.com> - 2015-12-29 09:13 -0800
        Re: Cannot get the value from dogpile.cache from different modules. Peter Otten <__peter__@web.de> - 2015-12-29 18:33 +0100
          Re: Cannot get the value from dogpile.cache from different modules. xeon Mailinglist <xeonmailinglist@gmail.com> - 2015-12-29 09:38 -0800
            Re: Cannot get the value from dogpile.cache from different modules. xeon Mailinglist <xeonmailinglist@gmail.com> - 2015-12-29 10:22 -0800
            Re: Cannot get the value from dogpile.cache from different modules. Peter Otten <__peter__@web.de> - 2015-12-29 20:11 +0100
    Re: Cannot get the value from dogpile.cache from different modules. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-12-29 17:14 +0000
      Re: Cannot get the value from dogpile.cache from different modules. xeon Mailinglist <xeonmailinglist@gmail.com> - 2015-12-29 09:23 -0800
      Re: Cannot get the value from dogpile.cache from different modules. xeon Mailinglist <xeonmailinglist@gmail.com> - 2015-12-29 09:27 -0800
        Re: Cannot get the value from dogpile.cache from different modules. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-12-29 19:22 +0000
          Re: Cannot get the value from dogpile.cache from different modules. xeon Mailinglist <xeonmailinglist@gmail.com> - 2015-12-29 14:57 -0800
            Re: Cannot get the value from dogpile.cache from different modules. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-12-29 23:30 +0000
        Re: Cannot get the value from dogpile.cache from different modules. Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-12-29 17:49 -0500

csiph-web