Lines Matching defs:key

101      * Returns the cache entry with the specified key if it exists, null otherwise.
104 public synchronized Entry get(String key) {
105 CacheHeader entry = mEntries.get(key);
111 File file = getFileForKey(key);
120 remove(key);
149 putEntry(entry.key, entry);
166 * @param key Cache key
170 public synchronized void invalidate(String key, boolean fullExpire) {
171 Entry entry = get(key);
177 put(key, entry);
183 * Puts the entry with the specified key into the cache.
186 public synchronized void put(String key, Entry entry) {
188 File file = getFileForKey(key);
191 CacheHeader e = new CacheHeader(key, entry);
195 putEntry(key, e);
206 * Removes the specified key from the cache if it exists.
209 public synchronized void remove(String key) {
210 boolean deleted = getFileForKey(key).delete();
211 removeEntry(key);
213 VolleyLog.d("Could not delete cache entry for key=%s, filename=%s",
214 key, getFilenameForKey(key));
219 * Creates a pseudo-unique filename for the specified cache key.
220 * @param key The key to generate a file name for.
223 private String getFilenameForKey(String key) {
224 int firstHalfLength = key.length() / 2;
225 String localFilename = String.valueOf(key.substring(0, firstHalfLength).hashCode());
226 localFilename += String.valueOf(key.substring(firstHalfLength).hashCode());
231 * Returns a file object for the given cache key.
233 public File getFileForKey(String key) {
234 return new File(mRootDirectory, getFilenameForKey(key));
257 boolean deleted = getFileForKey(e.key).delete();
261 VolleyLog.d("Could not delete cache entry for key=%s, filename=%s",
262 e.key, getFilenameForKey(e.key));
279 * Puts the entry with the specified key into the cache.
280 * @param key The key to identify the entry by.
283 private void putEntry(String key, CacheHeader entry) {
284 if (!mEntries.containsKey(key)) {
287 CacheHeader oldEntry = mEntries.get(key);
290 mEntries.put(key, entry);
294 * Removes the entry identified by 'key' from the cache.
296 private void removeEntry(String key) {
297 CacheHeader entry = mEntries.get(key);
300 mEntries.remove(key);
328 /** The key that identifies the cache entry. */
329 public String key;
347 * @param key The key that identifies the cache entry
350 public CacheHeader(String key, Entry entry) {
351 this.key = key;
372 entry.key = ois.readUTF();
403 oos.writeUTF(key);