Code example for Cache

Methods: getIfPresent

0
        this.cache = cacheBuilder.build();
    } 
 
    @Override 
    public Query get(QueryParserSettings queryString) {
        Query value =  cache.getIfPresent(queryString);
        if (value != null) { 
            return value.clone(); 
        } else { 
            return null; 
        } 
    } 
 
    @Override 
    public void put(QueryParserSettings queryString, Query query) {
        if (queryString.isCacheable()) {
            cache.put(queryString, query);
        } 
    }