def add(self, key, value, timeout=0):
     try:
         val = self._cache_master.getset(smart_str(key), pickle.dumps(value))
         self._cache_master.expire(smart_str(key), timeout or self.default_timeout)
         return val
     except redis.ConnectionError, e:
         logging.exception("ConnectionError %s" % e)
示例#2
0
 def set(self, key, value, timeout=0):
     try:
         self._cache_master.set(smart_str(key), pickle.dumps(value))
         self._cache_master.expire(smart_str(key), timeout
                                   or self.default_timeout)
     except redis.ConnectionError, e:
         logging.exception("ConnectionError %s" % e)
    def add(self, key, value, timeout=0):
        if isinstance(value, unicode):
            value = value.encode('utf-8')

        try:
            return self._cache.add(smart_str(key), value, timeout or self.default_timeout)
        except:
            logging.exception("memcache server desligado!")
示例#4
0
    def add(self, key, value, timeout=0):
        if isinstance(value, unicode):
            value = value.encode('utf-8')

        try:
            return self._cache.add(smart_str(key), value, timeout
                                   or self.default_timeout)
        except:
            logging.exception("memcache server desligado!")
 def get(self, key, default=None):
     try:
         val = self._cache_slave.get(smart_str(key))
         if val is None:
             return default
         else:
             return pickle.loads(val)
     except redis.ConnectionError, e:
         logging.exception("ConnectionError %s" % e)
示例#6
0
 def get(self, key, default=None):
     try:
         val = self._cache_slave.get(smart_str(key))
         if val is None:
             return default
         else:
             return pickle.loads(val)
     except redis.ConnectionError, e:
         logging.exception("ConnectionError %s" % e)
示例#7
0
 def get(self, key, default=None):
     try:
         val = self._cache.get(smart_str(key))
         if val is None:
             return default
         else:
             if isinstance(val, basestring):
                 return smart_unicode(val)
             else:
                 return val
     except:
         logging.exception("memcache server desligado!")
         return None
 def get(self, key, default=None):
     try:
         val = self._cache.get(smart_str(key))
         if val is None:
             return default
         else:
             if isinstance(val, basestring):
                 return smart_unicode(val)
             else:
                 return val
     except:
         logging.exception("memcache server desligado!")
         return None
def test_can_smart_str_numbers():
    assert smart_str(9888) == '9888'
 def delete(self, key):
     self._cache.delete(smart_str(key))
 def set(self, key, value, timeout=0):
     if isinstance(value, unicode):
         value = value.encode('utf-8')
     self._cache.set(smart_str(key), value, timeout or self.default_timeout)
示例#12
0
 def set(self, key, value, timeout=0):
     if isinstance(value, unicode):
         value = value.encode('utf-8')
     self._cache.set(smart_str(key), value, timeout or self.default_timeout)
 def delete(self, key):
     try:
         self._cache_master.delete(smart_str(key))
     except redis.ConnectionError, e:
         logging.exception("ConnectionError %s" % e)
def test_can_smart_str_only():
    assert smart_str(9888,strings_only=True) == 9888
示例#15
0
 def delete(self, key):
     try:
         self._cache_master.delete(smart_str(key))
     except redis.ConnectionError, e:
         logging.exception("ConnectionError %s" % e)
def test_can_smart_str():
    assert smart_str('acentuação') == 'acentuação'
示例#17
0
 def delete(self, key):
     self._cache.delete(smart_str(key))