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.

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 2015-12-29 17:49 -0500
Organization IISS Elusive Unicorn
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>

Show all headers | 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