Add getContentMetadata and applyContentMetadataMutations to Cache interface

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=189186679
This commit is contained in:
eguven 2018-03-15 08:07:14 -07:00 committed by Oliver Woodman
parent 234d611175
commit d9f2989c9e
2 changed files with 21 additions and 14 deletions

View File

@ -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);
}

View File

@ -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);
}