Example #1
0
 /**
  * Creates a cache span from an underlying cache file.
  *
  * @param file The cache file.
  * @return The span, or null if the file name is not correctly formatted.
  */
 public static CacheSpan createCacheEntry(File file) {
   Matcher matcher = cacheFilePattern.matcher(file.getName());
   if (!matcher.matches()) {
     return null;
   }
   return CacheSpan.createCacheEntry(
       matcher.group(1), Long.parseLong(matcher.group(2)), Long.parseLong(matcher.group(3)), file);
 }
Example #2
0
 /**
  * Renames the file underlying this cache span to update its last access time.
  *
  * @return A {@link CacheSpan} representing the updated cache file.
  */
 public CacheSpan touch() {
   long now = System.currentTimeMillis();
   File newCacheFile = getCacheFileName(file.getParentFile(), key, position, now);
   file.renameTo(newCacheFile);
   return CacheSpan.createCacheEntry(key, position, now, newCacheFile);
 }