public interface

Cache.Listener

 androidx.media3.datasource.cache.Cache.Listener

Subclasses:

CachedRegionTracker, NoOpCacheEvictor, LeastRecentlyUsedCacheEvictor, CacheEvictor

Overview

Listener of Cache events.

Summary

Methods
public voidonSpanAdded(Cache cache, CacheSpan span)

Called when a CacheSpan is added to the cache.

public voidonSpanRemoved(Cache cache, CacheSpan span)

Called when a CacheSpan is removed from the cache.

public voidonSpanTouched(Cache cache, CacheSpan oldSpan, CacheSpan newSpan)

Called when an existing CacheSpan is touched, causing it to be replaced.

Methods

public void onSpanAdded(Cache cache, CacheSpan span)

Called when a CacheSpan is added to the cache.

Parameters:

cache: The source of the event.
span: The added CacheSpan.

public void onSpanRemoved(Cache cache, CacheSpan span)

Called when a CacheSpan is removed from the cache.

Parameters:

cache: The source of the event.
span: The removed CacheSpan.

public void onSpanTouched(Cache cache, CacheSpan oldSpan, CacheSpan newSpan)

Called when an existing CacheSpan is touched, causing it to be replaced. The new CacheSpan is guaranteed to represent the same data as the one it replaces, however CacheSpan.file and CacheSpan.lastTouchTimestamp may have changed.

Note that for span replacement, Cache.Listener.onSpanAdded(Cache, CacheSpan) and Cache.Listener.onSpanRemoved(Cache, CacheSpan) are not called in addition to this method.

Parameters:

cache: The source of the event.
oldSpan: The old CacheSpan, which has been removed from the cache.
newSpan: The new CacheSpan, which has been added to the cache.