diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/Cache.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/Cache.java index 171aa0878a..bd76a8e1d0 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/Cache.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/Cache.java @@ -238,4 +238,23 @@ public interface Cache { * com.google.android.exoplayer2.C#LENGTH_UNSET} otherwise. */ long getContentLength(String key); + + /** + * Applies {@code mutations} to the {@link ContentMetadata} for the given key. A new {@link + * CachedContent} is added if there isn't one already with the given key. + * + * @param key The cache key for the data. + * @param mutations Contains mutations to be applied to the metadata. + * @throws CacheException If an error is encountered. + */ + void applyContentMetadataMutations(String key, ContentMetadataMutations mutations) + throws CacheException; + + /** + * Returns a snapshot of the {@link ContentMetadata} for the given key. + * + * @param key The cache key for the data. + * @return A snapshot of the {@link ContentMetadata} for the given key. + */ + ContentMetadata getContentMetadataSnapshot(String key); } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/SimpleCache.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/SimpleCache.java index 4a1d92ad76..dd7d10d64d 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/SimpleCache.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/SimpleCache.java @@ -412,26 +412,14 @@ public final class SimpleCache implements Cache { return index.getContentLength(key); } - /** - * Applies {@code mutations} to the {@link ContentMetadata} for the given key. A new {@link - * CachedContent} is added if there isn't one already with the given key. - * - * @param key The cache key for the data. - * @param mutations Contains mutations to be applied to the metadata. - * @throws CacheException If an error is encountered. - */ + @Override public void applyContentMetadataMutations(String key, ContentMetadataMutations mutations) throws CacheException { index.applyContentMetadataMutations(key, mutations); index.store(); } - /** - * Returns a snapshot of the {@link ContentMetadata} for the given key. - * - * @param key The cache key for the data. - * @return A snapshot of the {@link ContentMetadata} for the given key. - */ + @Override public ContentMetadata getContentMetadataSnapshot(String key) { return index.getContentMetadataSnapshot(key); }