class H2StatementCache {
    /** Last usage. */
    private volatile long lastUsage;

    /** */
    private final LinkedHashMap<H2CachedStatementKey, PreparedStatement> lruStmtCache;

    /**
     * @param size Maximum number of statements this cache can store.
     */
    H2StatementCache(int size) {
        lruStmtCache = new LinkedHashMap<H2CachedStatementKey, PreparedStatement>(size, .75f, true) {
            @Override protected boolean removeEldestEntry(Map.Entry<H2CachedStatementKey, PreparedStatement> eldest) {
                if (size() <= size)
                    return false;

                U.closeQuiet(eldest.getValue());

                return true;
            }
        };
    }

    /**
     * Caches a statement.
     *
     * @param key Key associated with statement.
     * @param stmt Statement which will be cached.
     */
    void put(H2CachedStatementKey key, @NotNull PreparedStatement stmt) {
        lastUsage = System.nanoTime();

        lruStmtCache.put(key, stmt);
    }

    /**
     * Retrieves cached statement.
     *
     * @param key Key for a statement.
     * @return Statement associated with a key.
     */
    @Nullable PreparedStatement get(H2CachedStatementKey key) {
        lastUsage = System.nanoTime();

        return lruStmtCache.get(key);
    }

    /**
     * Checks if the current cache has not been used for at least {@code nanos} nanoseconds.
     *
     * @param nanos Interval in nanoseconds.
     * @return {@code true} if the current cache has not been used for the specified period.
     */
    boolean inactiveFor(long nanos) {
        return System.nanoTime() - lastUsage >= nanos;
    }

    /**
     * Remove statement for given schema and SQL.
     *
     * @param schemaName Schema name.
     * @param sql SQL statement.
     */
    void remove(String schemaName, String sql, byte qryFlags) {
        lastUsage = System.nanoTime();

        lruStmtCache.remove(new H2CachedStatementKey(schemaName, sql, qryFlags));
    }

    /**
     * @return Cache size.
     */
    int size() {
        return lruStmtCache.size();
    }

    /** */
    public static byte queryFlags(QueryDescriptor qryDesc) {
        assert qryDesc != null;

        return queryFlags(qryDesc.distributedJoins(), qryDesc.enforceJoinOrder());
    }

    /** */
    public static byte queryFlags(boolean distributedJoins, boolean enforceJoinOrder) {<FILL_FUNCTION_BODY>}
}

        return (byte)((distributedJoins ? 1 : 0) + (enforceJoinOrder ? 2 : 0));
    
<no_super_class>