Python pylibmc.Client() Examples
The following are 30
code examples of pylibmc.Client().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pylibmc
, or try the search function
.
Example #1
Source File: cache.py From Flask with Apache License 2.0 | 6 votes |
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
Example #2
Source File: cache.py From PhonePi_SampleServer with MIT License | 6 votes |
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
Example #3
Source File: cache.py From cloud-playground with Apache License 2.0 | 6 votes |
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
Example #4
Source File: memcachedcache.py From cutout with MIT License | 6 votes |
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
Example #5
Source File: cache.py From pyRevit with GNU General Public License v3.0 | 6 votes |
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
Example #6
Source File: cache.py From syntheticmass with Apache License 2.0 | 6 votes |
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
Example #7
Source File: cache.py From arithmancer with Apache License 2.0 | 6 votes |
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
Example #8
Source File: cache.py From appengine-try-python-flask with Apache License 2.0 | 6 votes |
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
Example #9
Source File: cache.py From Flask-P2P with MIT License | 6 votes |
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
Example #10
Source File: cache.py From Financial-Portfolio-Flask with MIT License | 6 votes |
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
Example #11
Source File: app_cfg.py From allura with Apache License 2.0 | 6 votes |
def _setup_bytecode_cache(cls): cache_type = config.get('jinja_bytecode_cache_type') bcc = None try: if cache_type == 'memcached' and config.get('memcached_host'): import pylibmc from jinja2 import MemcachedBytecodeCache client = pylibmc.Client([config['memcached_host']]) bcc_prefix = 'jinja2/{}/'.format(jinja2.__version__) if six.PY3: bcc_prefix += 'py{}{}/'.format(sys.version_info.major, sys.version_info.minor) bcc = MemcachedBytecodeCache(client, prefix=bcc_prefix) elif cache_type == 'filesystem': from jinja2 import FileSystemBytecodeCache bcc = FileSystemBytecodeCache(pattern='__jinja2_{}_%s.cache'.format(jinja2.__version__)) except: log.exception("Error encountered while setting up a" + " %s-backed bytecode cache for Jinja" % cache_type) return bcc
Example #12
Source File: cache.py From data with GNU General Public License v3.0 | 6 votes |
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
Example #13
Source File: cache.py From data with GNU General Public License v3.0 | 6 votes |
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
Example #14
Source File: cache.py From data with GNU General Public License v3.0 | 6 votes |
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
Example #15
Source File: cache.py From jbox with MIT License | 6 votes |
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
Example #16
Source File: cache.py From Flask with Apache License 2.0 | 6 votes |
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
Example #17
Source File: cache.py From RSSNewsGAE with Apache License 2.0 | 6 votes |
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
Example #18
Source File: populate_db.py From zulip with Apache License 2.0 | 6 votes |
def clear_database() -> None: # Hacky function only for use inside populate_db. Designed to # allow running populate_db repeatedly in series to work without # flushing memcached or clearing the database manually. # With `zproject.test_settings`, we aren't using real memcached # and; we only need to flush memcached if we're populating a # database that would be used with it (i.e. zproject.dev_settings). if default_cache['BACKEND'] == 'django_pylibmc.memcached.PyLibMCCache': pylibmc.Client( [default_cache['LOCATION']], binary=True, username=default_cache["USERNAME"], password=default_cache["PASSWORD"], behaviors=default_cache["OPTIONS"], ).flush_all() model: Any = None # Hack because mypy doesn't know these are model classes for model in [Message, Stream, UserProfile, Recipient, Realm, Subscription, Huddle, UserMessage, Client, DefaultStream]: model.objects.all().delete() Session.objects.all().delete() # Suppress spammy output from the push notifications logger
Example #19
Source File: cache.py From data with GNU General Public License v3.0 | 6 votes |
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
Example #20
Source File: memcached.py From nzb-subliminal with GNU General Public License v3.0 | 6 votes |
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
Example #21
Source File: cache.py From data with GNU General Public License v3.0 | 6 votes |
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
Example #22
Source File: cache.py From android_universal with MIT License | 5 votes |
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
Example #23
Source File: cache.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 5 votes |
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
Example #24
Source File: test_plugin.py From pytest-services with MIT License | 5 votes |
def test_memcached(request, memcached, memcached_socket): """Test memcached service.""" mc = pylibmc.Client([memcached_socket]) mc.set('some', 1) assert mc.get('some') == 1 # check memcached cleaner request.getfixturevalue('memcached_clean') assert mc.get('some') is None
Example #25
Source File: tests_basic.py From easy_cache with MIT License | 5 votes |
def is_memcache(self): try: # noinspection PyUnresolvedReferences from memcache import Client except ImportError: return False return isinstance(getattr(self._cache, '_cache', None), Client)
Example #26
Source File: common.py From itchatmp with MIT License | 5 votes |
def __init__(self): try: import pylibmc except ImportError: logger.info('pylibmc is not installed') sys.exit() self.__storage = pylibmc.Client()
Example #27
Source File: backends.py From syntheticmass with Apache License 2.0 | 5 votes |
def __init__(self, servers=None, default_timeout=300, key_prefix=None, username=None, password=None): BaseCache.__init__(self, default_timeout) if servers is None: servers = ['127.0.0.1:11211'] import pylibmc self._client = pylibmc.Client(servers, username=username, password=password, binary=True) self.key_prefix = key_prefix
Example #28
Source File: tests_basic.py From easy_cache with MIT License | 5 votes |
def is_pylibmc(self): try: # noinspection PyUnresolvedReferences from pylibmc import Client except ImportError: return False return isinstance(getattr(self._cache, '_cache', None), Client)
Example #29
Source File: requesthandler.py From PPP-QuestionParsing-Grammatical with GNU Affero General Public License v3.0 | 5 votes |
def connect_memcached(): mc = memcache.Client(Config().memcached_servers) return mc
Example #30
Source File: lock.py From django-mmc with GNU General Public License v2.0 | 5 votes |
def __init__(self, script): try: from memcache import Client except ImportError: from pylibmc import Client super(MemcacheLock, self).__init__(script) self._cli = Client(**defaults.MEMCACHED_CONFIG) self.random_wait()