because memcached does not provide a function to check if a key is existed
        so here is a heck way, if the value is None, then raise Exception
961330
def get(self, key):
        
        if isinstance(key, unicode):
            key = key.encode('utf-8')
        v = self.client.get(key)
        if v is None:
            raise KeyError("Cache key [%s] not found" % key)
        else:
            return v
747545
function(...args) {
      const cacheKey = keySelector(...args);

      if (isValidCacheKey(cacheKey)) {
        let cacheResponse = cache.get(cacheKey);

        if (cacheResponse === undefined) {
          cacheResponse = selectorCreator(...funcs);
          cache.set(cacheKey, cacheResponse);
        }

        return cacheResponse(...args);
      }
      console.warn(
        `[re-reselect] Invalid cache key "${cacheKey}" has been returned by keySelector function.`
      );
      return undefined;
    }
716787
def getCachedOrUpdatedValue(self, key):
        
        try:
            return self._VALUES[key]
        except KeyError:
            return self.getValue(key)
27058
def request(op, *args)
      verify_state
      raise Dalli::NetworkError, "#{name} is down: #{@error} #{@msg}. If you are sure it is running, ensure memcached version is > 1.4." unless alive?
      begin
        send(op, *args)
      rescue Dalli::MarshalError => ex
        Dalli.logger.error "Marshalling error for key '#{args.first}': #{ex.message}"
        Dalli.logger.error "You are trying to cache a Ruby object which cannot be serialized to memcached."
        Dalli.logger.error ex.backtrace.join("\n\t")
        false
      rescue Dalli::DalliError, Dalli::NetworkError, Dalli::ValueOverMaxSize, Timeout::Error
        raise
      rescue => ex
        Dalli.logger.error "Unexpected exception during Dalli request: #{ex.class.name}: #{ex.message}"
        Dalli.logger.error ex.backtrace.join("\n\t")
        down!
      end
    end
953021
def validate_key(self, key):
        
        if len(key) > 250:
            raise ValueError(
                "Cache key is longer than the maxmimum 250 characters: {}"
                .format(key),
            )
        return super(MySQLCache, self).validate_key(key)
1289834
public function grabValueFromMemcached($key)
    {
        $value = $this->memcache->get($key);
        $this->debugSection("Value", $value);

        return $value;
    }
1118586
protected function getValue($key)
    {
        $getResult = $this->getClient()->get($key);

        if ($this->getClient()->getResultCode() === \Memcached::RES_NOTFOUND) {
            throw new KeyNotFoundException();
        } elseif ($getResult === false) {
            throw new \Exception($this->getClient()->getResultMessage(), $this->getClient()->getResultCode());
        }

        return $getResult;
    }
902252
def cache_key(self):
        """"""
        try:
            return self.path
        except TypeError:
            raise TypeError("self.path is invalild: '{}', '{}'".format(str(self.path), type(self.path)))
730684
def _process_key_val(self, instance, key, val):
        '''
        
        '''
        if instance.check_precondition(key, val):
            combined = '{k}:{v}'.format(k=key, v=val)
            self._increment_total_stat(combined)
            self._increment_plugin_stat(
                instance.__class__.__name__,
                combined)
            instance.handle(key, val)
            self.redis_conn.delete(key)
            failkey = self._get_fail_key(key)
            if self.redis_conn.exists(failkey):
                self.redis_conn.delete(failkey)
319064
def exists(self, key, fresh=False):
        
        key = key.upper()
        if key in self._deleted:
            return False
        return self.get(key, fresh=fresh, default=missing) is not missing
556872
function useNonce($server_url, $timestamp, $salt)
    {
        global $Auth_OpenID_SKEW;
        
        // save one request to memcache when nonce obviously expired 
        if (abs($timestamp - time()) > $Auth_OpenID_SKEW) {
            return false;
        }
        
        // SETNX will set the value only of the key doesn't exist yet.
        $nonceKey = $this->nonceKey($server_url, $salt);
        $added = $this->redis->setnx($nonceKey, "1");
        if ($added) {
            // Will set expiration
            $this->redis->expire($nonceKey, $Auth_OpenID_SKEW);
            return true;
        } else {
            return false;
        }
    }
697048
public long get() throws MemcachedException, InterruptedException, TimeoutException {
    Object result = this.memcachedClient.get(this.key);
    if (result == null) {
      throw new MemcachedClientException("key is not existed.");
    } else {
      if (result instanceof Long)
        return (Long) result;
      else
        return Long.valueOf(((String) result).trim());
    }
  }
1186129
public function haveInMemcached($key, $value, $expiration = null)
    {
        switch (get_class($this->memcache)) {
            case 'Memcache':
                $this->assertTrue($this->memcache->set($key, $value, null, $expiration));
                break;
            case 'Memcached':
                $this->assertTrue($this->memcache->set($key, $value, $expiration));
                break;
        }
    }
207485
def exists(self):
        
        try:
            key = self.key
        except DoesNotExist:
            """
            If the object doesn't exists anymore, its PK is deleted, so the
            "self.key" call will raise a DoesNotExist exception. We catch it
            to return False, as the field doesn't exists too.
            """
            return False
        else:
            return self.connection.exists(key)
818496
public function has($key)
    {
        // Got help from here: http://stackoverflow.com/a/3091136/1208233
        if (!$this->memcached->add($key, true, 10)) {
            // If not possible to add, then the key exists
            return true;
        } else {
            // If possible to add, then the key doesn't exist
            $this->memcached->delete($key);
            return false;
        }
    }
1142045
def increment(self, key, value=1):
        
        return self._memcache.incr(self._prefix + key, value)
410779
def cache_key_exist(self, key):
        """"""
        key_exist = True if cache.get(key) else False
        status = 200 if key_exist else 404
        return json_success(json.dumps({'key_exist': key_exist}),
                            status=status)