{@inheritDoc}

Because query cache key contains all the SQL statement and addtional information,
it's too long for memcached cache key.
So shorten the key by hashing.
331185
protected String refineKey(Object key) {
        String refinedKey = DigestUtils.md5Hex(String.valueOf(key)) + "_" + String.valueOf(key.hashCode());
        log.debug("QueryResultCache refineKey original {} to {}", key, refinedKey);
        return refinedKey;
    }
917297
function(text, options) {
    var execute, queried;
    queried = p.defer();
    // caching disabled unless duration is specified
    options = options != null ? options : {
      duration: 0
    };
    execute = function(params) {
      return db.prepare(text).then(function(stmt) {
        return stmt.execute(params).then(function(results) {
          if (options.duration > 0) {
            cache.store(text, results.rows, options.duration);
          }
          return queried.resolve(results.rows);
        }).done();
      }).done();
    };
    // return results directly if cache hit, run query if cache miss
    cache.get(text).then(function(results) {
      return queried.resolve(results);
    }, function(err) {
      if (err != null) {
        return queried.reject(err);
      } else {
        return execute();
      }
    }).done();
    return queried.promise;
  }
156475
public static function GetArr(string $query, bool $cached = false, int $ttl = 60, array $tags = [], bool $prolong = true)
        {
            if ($md5 = self::$useCache && $cached ? md5($query) : "") {
                if (($data = Memcache::get("pgsql:arr:{$md5}")) !== false) {
                    if ($prolong) {
                        Memcache::set("pgsql:arr:{$md5}", $data, $ttl, $tags);
                    }

                    return $data;
                }
            }

            $res = self::Query($query);

            if (!$res || !pg_num_rows($res)) {
                return [];
            }

            $data = pg_fetch_all($res);
            foreach ($data as &$row) {
                $i = 0;
                foreach ($row as &$field) {
                    self::TranspileFieldTypes($res, $field, $i++);
                }
            }

            if ($md5) {
                Memcache::set("pgsql:arr:{$md5}", $data, $ttl, $tags);
            }

            return $data ?: [];
        }
471684
@Override
	public String getCacheKey(String name, Tree params, String... keys) {
		if (params == null) {
			return name;
		}
		StringBuilder buffer = new StringBuilder(128);
		serializeKey(buffer, params, keys);
		String serializedParams = buffer.toString();
		int paramsLength = serializedParams.length();
		if (maxParamsLength < 44 || paramsLength <= maxParamsLength) {

			// Key = action name : serialized key
			return name + ':' + serializedParams;
		}

		// Length of unhashed part (begining of the serialized params)
		int prefixLength = maxParamsLength - 44;

		// Create SHA-256 hash from the entire key
		byte[] bytes = serializedParams.getBytes(StandardCharsets.UTF_8);
		MessageDigest hasher = hashers.poll();
		if (hasher == null) {
			try {
				hasher = MessageDigest.getInstance("SHA-256");
			} catch (Exception cause) {
				logger.warn("Unable to get SHA-256 hasher!", cause);
				return name + ':' + serializedParams;
			}
		}
		bytes = hasher.digest(bytes);
		hashers.add(hasher);

		// Concatenate key and the 44 character long hash
		String base64 = BASE64.encode(bytes);
		if (prefixLength < 1) {

			// Fully hashed key = action name : hash code
			return name + ':' + base64;
		}

		// Partly hashed key = action name : beginig of the prefix + hash code
		return name + ':' + serializedParams.substring(0, prefixLength) + base64;
	}
371175
function cacheQuery () {
    // debug
    debug('view:id:record:get', this.idCacheKeys, this.ids)
    // attempt to get from cache
    return this.cache.redis.mgetAsync(this.idCacheKeys)
    // check result
    .then(cached => this.cacheQueryResult(cached))
}
15542
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
	{
		if ($nrows > 0) {
			if ($offset <= 0) $str = " ROWS $nrows ";
			else {
				$a = $offset+1;
				$b = $offset+$nrows;
				$str = " ROWS $a TO $b";
			}
		} else {
			// ok, skip
			$a = $offset + 1;
			$str = " ROWS $a TO 999999999"; // 999 million
		}
		$sql .= $str;

		return ($secs2cache) ?
				$this->CacheExecute($secs2cache,$sql,$inputarr)
			:
				$this->Execute($sql,$inputarr);
	}
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;
        }
    }
1344811
public function cache($key, $expires = null) {
        if ($this->getType() !== self::SELECT) {
            return $this;
        }

        $this->_cacheKey = $key;
        $this->_cacheLength = $expires;

        return $this;
    }
664192
@Override
	public <T> void cache(final Object key, final Object object, Class<T> clas) {
		this.logger.debug("@cache v2 ");

		if (object == null && !isAllowNullable()) {
			return;
		} else {
			this.logger.debug("logging key :", key, " with object : ", object, " with Class : ", clas);
			getCachableMap(clas).put(key, object);
		}
	}
935634
function cache($query, $result) {
        if ($this->isSelectStatement($query) === TRUE) $this->queries[$query] = $result;
        else return(FALSE);
        return(TRUE);
    }
1171958
public String calculateCacheKey(String sql, int[] columnIndexes) {
		StringBuilder tmp = new StringBuilder(sql.length()+4);
		tmp.append(sql);
		for (int i=0; i < columnIndexes.length; i++){
			tmp.append(columnIndexes[i]);
			tmp.append("CI,");
		}
		return tmp.toString();
	}
486312
function remove($key=null, $prefix_mode=false)
    {
        // Remove all keys
        if ($key === null) {
            $this->cache         = array();
            $this->cache_changes = array();
            $this->cache_sums    = array();
        }
        // Remove keys by name prefix
        else if ($prefix_mode) {
            foreach (array_keys($this->cache) as $k) {
                if (strpos($k, $key) === 0) {
                    $this->cache[$k] = null;
                    $this->cache_changes[$k] = false;
                    unset($this->cache_sums[$k]);
                }
            }
        }
        // Remove one key by name
        else {
            $this->cache[$key] = null;
            $this->cache_changes[$key] = false;
            unset($this->cache_sums[$key]);
        }

        // Remove record(s) from the backend
        $this->remove_record($key, $prefix_mode);
    }
252952
protected function generateCacheKey()
    {
        $name = $this->connection->getName();

        $data = $name.$this->toSql().serialize($this->getBindings());

        return hash(static::HASH_ALGO, $data);
    }
1170055
static function storeCache( $key )
    {
        $translationCache = eZTranslationCache::cacheTable();
        if ( !isset( $translationCache[$key] ) )
        {
            eZDebug::writeWarning( "Translation cache for key '$key' does not exist, cannot store cache", __METHOD__ );
            return;
        }
        $internalCharset = eZTextCodec::internalCharset();
//         $cacheFileKey = "$key-$internalCharset";
        $cacheFileKey = $key;
        $cacheFileName = md5( $cacheFileKey ) . '.php';

        $cache =& $translationCache[$key];

        if ( !file_exists( eZTranslationCache::cacheDirectory() ) )
        {
            eZDir::mkdir( eZTranslationCache::cacheDirectory(), false, true );
        }
        $php = new eZPHPCreator( eZTranslationCache::cacheDirectory(), $cacheFileName );
        $php->addRawVariable( 'eZTranslationCacheCodeDate', self::CODE_DATE );
        $php->addSpace();
        $php->addRawVariable( 'CacheInfo', array( 'charset' => $internalCharset ) );
        $php->addRawVariable( 'TranslationInfo', $cache['info'] );
        $php->addSpace();
        $php->addRawVariable( 'TranslationRoot', $cache['root'] );
        $php->store( true );
    }
571987
private void cacheUniqueSelectRef(Object object, MappedStatement mt, String cacheKey) {
		Collection<QueryMethodCache> mcs = queryCacheMethods.get(mt.getId().substring(0, mt.getId().lastIndexOf(SPLIT_PONIT))).values();
		outter:for (QueryMethodCache methodCache : mcs) {
			if(methodCache.isPk || methodCache.groupRalated)continue;
			try {	
				Object[] cacheFieldValues = new Object[methodCache.fieldNames.length];
				for (int i = 0; i < cacheFieldValues.length; i++) {
					if(methodCache.fieldNames[i] == null)break outter;
					cacheFieldValues[i] = ReflectUtils.getObjectValue(object, methodCache.fieldNames[i]);
					if(cacheFieldValues[i] == null)continue outter;
				}
				String fieldCacheKey = genarateQueryCacheKey(methodCache.keyPattern , cacheFieldValues);
				
				cacheFieldRefKey(fieldCacheKey,cacheKey, methodCache.getExpire());
				if(logger.isDebugEnabled())logger.debug("_autocache_ method[{}] add ref cacheKey:{}",mt.getId(),fieldCacheKey);
			} catch (Exception e) {
				logger.warn("cacheUniqueSelectRef:"+cacheKey,e);
			}
		}
	}
803136
public String calculateCacheKey(String sql, int autoGeneratedKeys) {
		StringBuilder tmp = new StringBuilder(sql.length()+4);
		tmp.append(sql);
		tmp.append(autoGeneratedKeys);
		return tmp.toString();
	}
879990
public static QueryCache getQueryCache(Cache<?, ?> cache) {
      return SecurityActions.getCacheGlobalComponentRegistry(cache.getAdvancedCache()).getComponent(QueryCache.class);
   }