/*
(non-Javadoc)

@see com.ibm.websphere.cache.CacheAdminMBean#getCacheIDsOnDisk(java.lang.String, java.lang.String)
6865
@Override
    public String[] getCacheIDsOnDisk(String cacheInstance, String pattern) throws javax.management.AttributeNotFoundException {

        // Get the cache for this cacheInstance
        DCache cache1 = getCache(cacheInstance);

        //Throw exception if disk caching is not enabled.  
        if (!cache1.getSwapToDisk()) {
            Tr.error(tc, "DYNA1051E", new Object[] { "getCacheIDsOnDisk", cacheInstance });
            throw new AttributeNotFoundException("Disk caching is not enabled.");
        }
        // Check that the input pattern is a valid regular expression
        Pattern cpattern = checkPattern(pattern);

        List<String> matchSet = new ArrayList<String>(10);
        if (cache1.getIdsSizeDisk() > 0) {
            int index = 0;
            boolean more = false;

            do {

                more = false;
                Collection diskSet = cache1.getIdsByRangeDisk(index, 100);
                if (diskSet != null) {
                    if (true == diskSet.contains(HTODDynacache.DISKCACHE_MORE)) {
                        more = true; //are there any IDs on the disk
                    }
                }

                index = 1;
                diskSet.remove(HTODDynacache.DISKCACHE_MORE);
                Iterator idIterator = diskSet.iterator();
                while (idIterator.hasNext()) {
                    Object key = idIterator.next();
                    String skey = key.toString();
                    boolean matches = checkMatch(cpattern, skey);
                    if (matches) {
                        matchSet.add(skey);
                        //if (tc.isDebugEnabled()) {
                        //   Tr.debug(tc,"getCacheIDsOnDisk:  Disk Cache id = " +skey + " matches the pattern " + pattern + " for cacheInstance = " + cacheInstance);
                        //}
                    }
                }
            } while (more == true);
        }

        //Allocate output array #entries matched 
        String[] cids = matchSet.toArray(new String[matchSet.size()]);
        if (tc.isDebugEnabled())
            Tr.debug(tc, "getCacheIDsOnDisk: Exiting. Number of matches found = " + matchSet.size());
        return cids;
    }
463904
public static CommandCache getCommandCache(String cacheName) {
        final String methodName = "getCommandCache()";
        CommandCache cacheOut = null;
        if (servletCacheEnabled == false) {
            // DYNA1059W=DYNA1059W: WebSphere Dynamic Cache instance named {0} cannot be used because of Dynamic Servlet
            // cache service has not be started.
            Tr.error(tc, "DYNA1059W", new Object[] { cacheName });
        } else {
            if (cacheName != null) {
                try {
                    cacheOut = cacheUnit.getCommandCache(cacheName);
                } catch (Exception e) {
                    // DYNA1003E=DYNA1003E: WebSphere Dynamic Cache instance named {0} can not be initialized because of
                    // error {1}.
                    Tr.error(tc, "DYNA1003E", new Object[] { cacheName, e });
                }
            } else {
                cacheOut = ServerCache.commandCache;
            }
        }
        if (cacheOut == null && TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, methodName + " could not find CommandCache for cacheName=" + cacheName);
        }
        return cacheOut;
    }
1198807
private static String getCacheKey(String url, int maxWidth, int maxHeight, ScaleType scaleType) {
        return "#W" + maxWidth + "#H" + maxHeight + "#S" + scaleType.ordinal() + url;
    }
1072087
@Override
    public <K, V> Cache<K, V> getCache(String cacheName) {
        return this.getCache(cacheName, true);
    }
932787
public static String getCacheKey(String uniqueId, String appRealm) {
        StringBuilder cacheKey = new StringBuilder();
        if (uniqueId == null || appRealm == null) {
            cacheKey.append(CACHE_KEY_PREFIX);
        } else {
            cacheKey.append(CACHE_KEY_PREFIX).append(uniqueId).append(CACHE_KEY_SEPARATOR).append(appRealm);
        }
        return cacheKey.toString();
    }
35645
public String getCacheKey(String name, Tree params, String... keys) {
		if (params == null) {
			return name;
		}
		StringBuilder key = new StringBuilder(128);
		key.append(name);
		key.append(':');
		serializeKey(key, params, keys);
		return key.toString();
	}
169815
private String getCacheKey(String[] keys, CmsDbContext dbc) {

        if (!dbc.getProjectId().isNullUUID()) {
            return "";
        }
        StringBuffer b = new StringBuffer(64);
        int len = keys.length;
        if (len > 0) {
            for (int i = 0; i < len; i++) {
                b.append(keys[i]);
                b.append('_');
            }
        }
        if (dbc.currentProject().isOnlineProject()) {
            b.append("+");
        } else {
            b.append("-");
        }
        return b.toString();
    }
193338
@Override
    public int getDepIdsSizeDisk() {
        final String methodName = "getDepIdsSizeDisk()";
        if (this.swapToDisk) {
            // TODO write code to support getDepIdsSizeDisk function
            if (tc.isDebugEnabled()) {
                Tr.debug(tc, methodName + " cacheName=" + cacheName + " ERROR because it is not implemented yet");
            }
        } else {
            if (this.featureSupport.isDiskCacheSupported() == false) {
                Tr.error(tc, "DYNA1064E", new Object[] { methodName, cacheName, this.cacheProviderName });
            } else {
                if (tc.isDebugEnabled()) {
                    Tr.debug(tc, methodName + " cacheName=" + cacheName + " no operation is done because the disk cache offload is not enabled");
                }
            }
        }
        return 0;
    }
284986
@CacheResult
  @Override
  public DOAuth2User get(@CacheKey Object parentKey, @CacheKey java.lang.Long id) throws IOException {
    return super.get(parentKey, id);
  }
874095
protected final <T> String getCacheRegionName(CriteriaQuery<T> criteriaQuery) {
        final Set<Root<?>> roots = criteriaQuery.getRoots();
        final Class<?> cacheRegionType = roots.iterator().next().getJavaType();
        final String cacheRegion = cacheRegionType.getName() + QUERY_SUFFIX;

        if (roots.size() > 1) {
            logger.warn(
                    "Query "
                            + criteriaQuery
                            + " in "
                            + this.getClass()
                            + " has "
                            + roots.size()
                            + " roots. The first will be used to generated the cache region name: "
                            + cacheRegion);
        }
        return cacheRegion;
    }
1275839
@Override
    public Set<String> getCacheNames() {
        Set<String> names = new HashSet<>(this.cm.getCacheNames());
        names.add(this.defaultCache);
        return names;
    }
122448
@Override
  public InetSocketAddress get(final Identifier key,
                               final Callable<InetSocketAddress> valueFetcher) throws ExecutionException {
    return cache.get(key, valueFetcher);
  }
1143506
public T get(final long _id)
    {
        return getCache4Id() == null ? null : getCache4Id().get(new Long(_id));
    }
1032090
void updateCacheId(BackedSession backedSess) {
        if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINER)) {
            LoggingUtil.SESSION_LOGGER_WAS.entering(methodClassName, methodNames[UPDATE_CACHE_ID]);
        }

        backedSess.getStoreCallback().sessionAffinityBroke(backedSess);

        int i = backedSess.getVersion();
        // if at all 9's, reset
        if (i == 9999) {
            backedSess.setVersion(BackedSession.initialCacheId);
        } else {
            i++;
            backedSess.setVersion(i);
        }
        if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINER)) {
            LoggingUtil.SESSION_LOGGER_WAS.exiting(methodClassName, methodNames[UPDATE_CACHE_ID]);
        }
    }
514582
public boolean enableDiskCache(Context context, int storageDevice) {
        Context appContext = context.getApplicationContext();

        String rootDir = null;
        if (storageDevice == DISK_CACHE_SDCARD
                && Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
            // SD-card available
            rootDir = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/data/"
                    + appContext.getPackageName() + "/cache";
        } else {
            File internalCacheDir = appContext.getCacheDir();
            // apparently on some configurations this can come back as null
            if (internalCacheDir == null) {
                return (isDiskCacheEnabled = false);
            }
            rootDir = internalCacheDir.getAbsolutePath();
        }

        setRootDir(rootDir);

        File outFile = new File(diskCacheDirectory);
        if (outFile.mkdirs()) {
            File nomedia = new File(diskCacheDirectory, ".nomedia");
            try {
                nomedia.createNewFile();
            } catch (IOException e) {
                Log.e(LOG_TAG, "Failed creating .nomedia file");
            }
        }

        isDiskCacheEnabled = outFile.exists();

        if (!isDiskCacheEnabled) {
            Log.w(LOG_TAG, "Failed creating disk cache directory " + diskCacheDirectory);
        } else {
            //Log.d(name, "enabled write through to " + diskCacheDirectory);

            // sanitize disk cache
            //Log.d(name, "sanitize DISK cache");
            sanitizeDiskCache();
        }

        return isDiskCacheEnabled;
    }
376444
protected Object getFromCache(String cacheName, String key) {
        try {
            ICache cache = getCache(cacheName);
            return cache != null ? cache.get(key) : null;
        } catch (CacheException e) {
            LOGGER.warn(e.getMessage(), e);
            return null;
        }
    }
71532
public synchronized Object getCacheKey(EvictionTableEntry evt) //3821 NK begin
    throws IOException,
                    EOFException,
                    FileManagerException,
                    ClassNotFoundException,
                    HashtableOnDiskException {
        Object key = null;
        if (filemgr == null) {
            throw new HashtableOnDiskException("No Filemanager");
        }

        HashtableEntry e = findEntry(evt, RETRIEVE_KEY);
        //TODO: Do we need to increment read_hits and read_requests
        if (e != null)
            key = e.getKey();
        return key;
    }