當前位置: 首頁>>代碼示例>>Python>>正文


Python memcache.Client方法代碼示例

本文整理匯總了Python中memcache.Client方法的典型用法代碼示例。如果您正苦於以下問題:Python memcache.Client方法的具體用法?Python memcache.Client怎麽用?Python memcache.Client使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在memcache的用法示例。


在下文中一共展示了memcache.Client方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: import_preferred_memcache_lib

# 需要導入模塊: import memcache [as 別名]
# 或者: from memcache import Client [as 別名]
def import_preferred_memcache_lib(self, servers):
        """Returns an initialized memcache client.  Used by the constructor."""
        try:
            import pylibmc
        except ImportError:
            pass
        else:
            return pylibmc.Client(servers)

        try:
            from google.appengine.api import memcache
        except ImportError:
            pass
        else:
            return memcache.Client()

        try:
            import memcache
        except ImportError:
            pass
        else:
            return memcache.Client(servers)


# backwards compatibility 
開發者ID:jojoin,項目名稱:cutout,代碼行數:27,代碼來源:memcachedcache.py

示例2: _imports

# 需要導入模塊: import memcache [as 別名]
# 或者: from memcache import Client [as 別名]
def _imports(self):
        global bmemcached
        import bmemcached

        class RepairBMemcachedAPI(bmemcached.Client):
            """Repairs BMemcached's non-standard method
            signatures, which was fixed in BMemcached
            ef206ed4473fec3b639e.

            """

            def add(self, key, value):
                try:
                    return super(RepairBMemcachedAPI, self).add(key, value)
                except ValueError:
                    return False

        self.Client = RepairBMemcachedAPI 
開發者ID:caronc,項目名稱:nzb-subliminal,代碼行數:20,代碼來源:memcached.py

示例3: test_patch_memcache

# 需要導入模塊: import memcache [as 別名]
# 或者: from memcache import Client [as 別名]
def test_patch_memcache():
    """Returns if no memcache.

    NB:
        test key -> 11212
        zzzzzzzzzz key -> 11211
    """
    monkey.patch_memcache()

    import memcache

    mc = memcache.Client(["127.0.0.1:11211", "127.0.0.0:11212"])
    mc.set("zzzzzzzzzz", 1, 2)
    mc.get("zzzzzzzzzz")
    mc.get("test")
    mc.get((0, "zzzzzzzzzz"))

    assert isinstance(mc.uhashring, HashRing) 
開發者ID:ultrabug,項目名稱:uhashring,代碼行數:20,代碼來源:test_monkey.py

示例4: __cache_get

# 需要導入模塊: import memcache [as 別名]
# 或者: from memcache import Client [as 別名]
def __cache_get (self):
		caches = self.__config['caches']
		if not caches:
			return None
		if self.__config['nocache']:
			return None
		try:
			cache = self.__caches.get_nowait()
			return cache
		except:
			pass
		try:
			import memcache
		except:
			return None
		cache = memcache.Client(self.__config['caches'])
		return cache
	
	# 釋放一個 memcached客戶端 
開發者ID:skywind3000,項目名稱:collection,代碼行數:21,代碼來源:cfs.py

示例5: get_memcache_config

# 需要導入模塊: import memcache [as 別名]
# 或者: from memcache import Client [as 別名]
def get_memcache_config(self):
        '''Try to get the config from Amazon in a short time.  If this
        fails, fall back to the existing config, or if there is none,
        to a dummy connection to localhost'''
        have_config = self.last_memcache_config is not None
        timeout = 0.5 if have_config else 5.0
        try:
            discovered = elasticache_auto_discovery.discover(
                self.elasticache_config, time_to_timeout=timeout)
        except socket.error:
            logger.warning('Could not fetch ElastiCache configuration for %s'
                           % self.elasticache_config, exc_info=True)
            if have_config:
                return self.last_memcache_config
            # return a dummy value
            logger.warning('No existing ElastiCache configuration for %s; '
                           'falling back to a dummy configuration'
                           % self.elasticache_config)
            return ['127.0.0.1:11211']
        # re-format for input to memcache.Client()
        memcache_config = ['%s:%s' % (e[1], e[2]) for e in discovered]
        self.last_memcache_config = memcache_config
        return memcache_config 
開發者ID:mozilla,項目名稱:build-relengapi,代碼行數:25,代碼來源:memcached.py

示例6: setup

# 需要導入模塊: import memcache [as 別名]
# 或者: from memcache import Client [as 別名]
def setup(cls, **kwargs):
        """Set up the storage system for memcached-based sessions.

        This should only be called once per process; this will be done
        automatically when using sessions.init (as the built-in Tool does).
        """
        for k, v in kwargs.items():
            setattr(cls, k, v)

        import memcache
        cls.cache = memcache.Client(cls.servers) 
開發者ID:cherrypy,項目名稱:cherrypy,代碼行數:13,代碼來源:sessions.py

示例7: import_preferred_memcache_lib

# 需要導入模塊: import memcache [as 別名]
# 或者: from memcache import Client [as 別名]
def import_preferred_memcache_lib(self, servers):
        """Returns an initialized memcache client.  Used by the constructor."""
        try:
            import pylibmc
        except ImportError:
            pass
        else:
            return pylibmc.Client(servers)

        try:
            from google.appengine.api import memcache
        except ImportError:
            pass
        else:
            return memcache.Client()

        try:
            import memcache
        except ImportError:
            pass
        else:
            return memcache.Client(servers)

        try:
            import libmc
        except ImportError:
            pass
        else:
            return libmc.Client(servers)


# backwards compatibility 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:34,代碼來源:cache.py

示例8: gettoken

# 需要導入模塊: import memcache [as 別名]
# 或者: from memcache import Client [as 別名]
def gettoken():
    memcached_host=cf.get("memcached", "host")
    try:
        mc = memcache.Client(memcached_host)
        if mc.get('weixintoken')==None:
            corp_id = cf.get("wechat", "corp_id")
            corp_secret = cf.get("wechat", "corp_secret")
            gettoken_url = 'https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=' + \
                corp_id + '&corpsecret=' + corp_secret
            token_file = urllib.request.urlopen(gettoken_url)
            token_data = token_file.read().decode('utf-8')
            token_json = json.loads(token_data)
            token_json.keys()
            token = token_json['access_token']
            mc.set('weixintoken',token,time=7000)
        else:
            token = mc.get('weixintoken')
    except Exception as e:
            corp_id = cf.get("wechat", "corp_id")
            corp_secret = cf.get("wechat", "corp_secret")
            gettoken_url = 'https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=' + \
                corp_id + '&corpsecret=' + corp_secret
            token_file = urllib.request.urlopen(gettoken_url)
            token_data = token_file.read().decode('utf-8')
            token_json = json.loads(token_data)
            token_json.keys()
            token = token_json['access_token']
    return token 
開發者ID:superbigsea,項目名稱:zabbix-wechat,代碼行數:30,代碼來源:common.py

示例9: __init__

# 需要導入模塊: import memcache [as 別名]
# 或者: from memcache import Client [as 別名]
def __init__(self, servers):
        # keep a reference to the current batch and to the underlying library's client object
        self.batch = _MCBatch(self)
        self._mc_client = memcache.Client(servers) 
開發者ID:quora,項目名稱:asynq,代碼行數:6,代碼來源:batching.py

示例10: import_preferred_memcache_lib

# 需要導入模塊: import memcache [as 別名]
# 或者: from memcache import Client [as 別名]
def import_preferred_memcache_lib(self, servers):
        """Returns an initialized memcache client.  Used by the constructor."""
        try:
            import pylibmc
        except ImportError:
            pass
        else:
            return pylibmc.Client(servers)

        try:
            from google.appengine.api import memcache
        except ImportError:
            pass
        else:
            return memcache.Client()

        try:
            import memcache
        except ImportError:
            pass
        else:
            return memcache.Client(servers)

        try:
            import libmc
        except ImportError:
            pass
        else:
            return libmc.Client(servers) 
開發者ID:pallets,項目名稱:cachelib,代碼行數:31,代碼來源:memcached.py

示例11: __init__

# 需要導入模塊: import memcache [as 別名]
# 或者: from memcache import Client [as 別名]
def __init__(self, log_variables):
        self.shared = memcache.Client(['127.0.0.1:11211'], debug=0)
        self.log_variables = log_variables 
開發者ID:OpenAgricultureFoundation,項目名稱:openag_brain_box,代碼行數:5,代碼來源:data_logger.py

示例12: __init__

# 需要導入模塊: import memcache [as 別名]
# 或者: from memcache import Client [as 別名]
def __init__(self):
        GPIO.setmode(GPIO.BCM) # Broadcom pin-numbering scheme
        self.shared = memcache.Client(['127.0.0.1:11211'], debug=0)
        self.relay_pins = [27,22,23,24] # <-- BCM pins, corresponding header pins [13,15,16,18] and colors [org,grn,blu,gry]
        self.ph = None
        self.ec = None
        self.water_temp = None
        self.air_temp = None
        self.humidity = None
        self.co2 = None
        self.o2 = None
        self.desired_air_temp = 30
        self.temperature_lower_band = 1
        self.heater_overshoot = 0.5
        self.desired_humidity = 85
        self.humidity_lower_band = 5
        self.humidifier_overshoot = 2.5
        self.heater_is_on = False
        self.humidifier_is_on = False

        # Check for setpoints in setpoints.csv file
        with open('/home/pi/openag_brain_box/ui/setpoints.csv', mode='r') as setpoints_file:
            reader = csv.reader(setpoints_file)
            setpoints = {rows[0]:rows[1] for rows in reader}
            logger.debug(setpoints)
            try:
                self.desired_air_temp = float(setpoints["air_temperature"])
                self.desired_humidity = float(setpoints["humidity"])
                logger.info("Set air temp to {}, humidity to {}".format(self.desired_air_temp, self.desired_humidity))
            except:
                logger.warning("Unable to parse setpoints file, setpoints are set to default values")

            self.shared.set("desired_air_temperature", "{0:.1f}".format(self.desired_air_temp))
            self.shared.set("desired_humidity", "{0:.1f}".format(self.desired_humidity))

        # Initialize relays to be OFF
        for pin in self.relay_pins:
            GPIO.setup(pin, GPIO.OUT)
            GPIO.output(pin, GPIO.HIGH) 
開發者ID:OpenAgricultureFoundation,項目名稱:openag_brain_box,代碼行數:41,代碼來源:actuators.py

示例13: __init__

# 需要導入模塊: import memcache [as 別名]
# 或者: from memcache import Client [as 別名]
def __init__(self):
        try:
            pygame.init()
            pygame.camera.init()
            pygame.mouse.set_visible(False)
            self.screen = pygame.display.set_mode((800,480),pygame.NOFRAME)
            self.cam_list = pygame.camera.list_cameras()
            self.webcam = pygame.camera.Camera(self.cam_list[0],(32,24))
            self.webcam.start()
            logger.info('Initialized pygame display')
        except:
            logger.warning('Unable to initialize pygame display')
        try:
            self.shared = memcache.Client(['127.0.0.1:11211'], debug=0)
            logger.info('Initialized memcache client')
        except:
            logger.warning('Unable to initialize memcache client')

        self.canny = False
        self.ph = '6.5'
        self.ec = '3.2'
        self.water_temp = '20.1'
        self.air_temp = '21.1'
        self.humidity = '38'
        self.co2 = '410'
        self.o2 = '17.1'
        # self.figure = matplotlib.pyplot.figure()
        # self.plot = self.figure.add_subplot(111)
        # self.runSeabornEx() 
開發者ID:OpenAgricultureFoundation,項目名稱:openag_brain_box,代碼行數:31,代碼來源:gui.py

示例14: __init__

# 需要導入模塊: import memcache [as 別名]
# 或者: from memcache import Client [as 別名]
def __init__(self, config, logger):
        self.mc = memcache.Client(config.MEMCACHED_CONFIG)
        self.config = config
        self.logger = logger 
開發者ID:Staffjoy,項目名稱:chomp-decomposition,代碼行數:6,代碼來源:cache.py


注:本文中的memcache.Client方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。