当前位置: 首页>>代码示例>>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;未经允许,请勿转载。