public String apply ( CharBuffer charValue , CacheScope cacheScope ) { int keyLength = charValue . length ( ) ; if ( ( lengthLimit < 0 || keyLength <= lengthLimit ) ) { Map < CharBuffer , String > cache = ( cacheScope == CacheScope . GLOBAL_SCOPE ) ? globalCache : applicationCache ; String value = cache . get ( charValue ) ; if ( value == null ) { value = charValue . consume ( ( k , v ) -> { cache . put ( k , v ) ; } ) ; } else { // System.out.println("cache hit"); } return value ; } return charValue . toString ( ) ; }
returns a object of type T that may be interned at the specified scope to reduce heap consumption