mirror of
https://github.com/samsonjs/media.git
synced 2026-04-08 11:45:51 +00:00
Improve CacheKeyFactory documentation
- To make it clear that cache keys are for whole resources - To explicitly make it clear to implementors that deriving a cache key from position and length is invalid. We've seen at least one developer trying to do this [1], so it seems worthwhile to be explicit! [1] https://github.com/google/ExoPlayer/issues/5978#issuecomment-618977036 Issue: #5978 PiperOrigin-RevId: 312643930
This commit is contained in:
parent
03d9375872
commit
63522ea554
1 changed files with 8 additions and 3 deletions
|
|
@ -25,10 +25,15 @@ public interface CacheKeyFactory {
|
|||
(dataSpec) -> dataSpec.key != null ? dataSpec.key : dataSpec.uri.toString();
|
||||
|
||||
/**
|
||||
* Returns a cache key for the given {@link DataSpec}.
|
||||
* Returns the cache key of the resource containing the data defined by a {@link DataSpec}.
|
||||
*
|
||||
* @param dataSpec The data being cached.
|
||||
* @return The cache key.
|
||||
* <p>Note that since the returned cache key corresponds to the whole resource, implementations
|
||||
* must not return different cache keys for {@link DataSpec DataSpecs} that define different
|
||||
* ranges of the same resource. As a result, implementations should not use fields such as {@link
|
||||
* DataSpec#position} and {@link DataSpec#length}.
|
||||
*
|
||||
* @param dataSpec The {@link DataSpec}.
|
||||
* @return The cache key of the resource.
|
||||
*/
|
||||
String buildCacheKey(DataSpec dataSpec);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue