Enable caching to the phone's internal storage or SD card.

@param context
the current context
@param storageDevice
where to store the cached files, either {@link #DISK_CACHE_INTERNAL} or
{@link #DISK_CACHE_SDCARD})
@return
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;
    }
74322
public static Accumulator getAccumulatorOrNull(QueryCacheContext context,
                                                   String mapName, String cacheId, int partitionId) {
        PartitionAccumulatorRegistry accumulatorRegistry = getAccumulatorRegistryOrNull(context, mapName, cacheId);
        if (accumulatorRegistry == null) {
            return null;
        }
        return accumulatorRegistry.getOrNull(partitionId);
    }
1161807
public DeviceEnvelope addDevice(Device device) throws ApiException {
        ApiResponse<DeviceEnvelope> resp = addDeviceWithHttpInfo(device);
        return resp.getData();
    }
119113
private KeyCache<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess> getCache(OmemoDevice device) {
        KeyCache<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess> cache = caches.get(device);
        if (cache == null) {
            cache = new KeyCache<>();
            caches.put(device, cache);
        }
        return cache;
    }
627061
public final void useCache(final boolean useCache) {
        synchronized (cache) {
            this.useCache = useCache;
            logger.logDebug(getClass(), useCache ? "Enabled" : "Disabled" + " caching");

            if (!useCache) {
                clearCache();
            }
        }
    }
133362
def cache(self):
        
        if self.mode == 'spark':
            self.values.cache()
            return self
        else:
            notsupported(self.mode)
419067
static File getStorageFile(StorageDirectory sd, NameNodeFile type) {
    return new File(sd.getCurrentDir(), type.getName());
  }
304062
public static void preRegister(Context context) {
        context.put(FSInfo.class, new Context.Factory<FSInfo>() {
            public FSInfo make(Context c) {
                FSInfo instance = new CacheFSInfo();
                c.put(FSInfo.class, instance);
                return instance;
            }
        });
    }
1314651
boolean isAvailableDeviceId(OmemoDevice userDevice, int id) {
        LOGGER.log(Level.INFO, "Check if id " + id + " is available...");

        // Lookup local cached device list
        BareJid ownJid = userDevice.getJid();
        OmemoCachedDeviceList cachedDeviceList;

        cachedDeviceList = loadCachedDeviceList(userDevice, ownJid);

        if (cachedDeviceList == null) {
            cachedDeviceList = new OmemoCachedDeviceList();
        }
        // Does the list already contain that id?
        return !cachedDeviceList.contains(id);
    }
1204940
private Resource mightCache(String key, Resource fileResource) {
        if ( ! isDevMode() ) {
            lookupCache.put(key,fileResource);
        }
        return fileResource;
    }
626902
public static <S> StorageTree resolvedTree(S context, ExtTree<S, ResourceMeta> authStorage) {
        return ResolvedExtTree.with(context, authStorage);
    }
227488
public static boolean sdCardIsAvailable() {
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
            return Environment.getExternalStorageDirectory().canWrite();
        } else
            return false;
    }
1186857
function (contextModel, properties) {
                    var cacheId = this.createContextCacheId(contextModel, properties);

                    if (!cacheId) {
                        // empty cacheId indicates the current context
                        return this;
                    }

                    if (!this.$contextCache.hasOwnProperty(cacheId)) {
                        this.$contextCache[cacheId] = this.$dataSource.createContext(contextModel, properties, this);
                    }

                    return this.$contextCache[cacheId];
                }
1328729
@Api
	public void setUseCache(boolean useCache) {
		if (null == cacheManagerService && useCache) {
			log.warn("The caching plugin needs to be available to cache WMS requests. Not setting useCache.");
		} else {
			this.useCache = useCache;
		}
	}
960906
private static File createReserveDiskCacheDir(Context context) {
		File cacheDir = StorageUtils.getCacheDirectory(context, false);
		File individualDir = new File(cacheDir, "uil-images");
		if (individualDir.exists() || individualDir.mkdir()) {
			cacheDir = individualDir;
		}
		return cacheDir;
	}
785116
public GetDevicesInPlacementResult withDevices(java.util.Map<String, String> devices) {
        setDevices(devices);
        return this;
    }
356297
static StorageCache initCache(Configuration configuration) {
    if (configuration.getBoolean(Configuration.CACHE_ENABLED) && configuration.getLong(Configuration.CACHE_BYTES) > 0) {
      return new StorageCache(configuration);
    } else {
      return new DisabledCache();
    }
  }