Package com.google.android.exoplayer2.upstream.cache

## Interface Cache.Listener

- All Known Subinterfaces:
    `CacheEvictor`
  All Known Implementing Classes:
    `CachedRegionTracker`, `LeastRecentlyUsedCacheEvictor`, `NoOpCacheEvictor`
  Enclosing interface:
    Cache

      public static interface Cache.Listener

  Listener of `Cache` events.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `onSpanAdded​(Cache cache, CacheSpan span)` | Called when a `CacheSpan` is added to the cache.
    `void` | `onSpanRemoved​(Cache cache, CacheSpan span)` | Called when a `CacheSpan` is removed from the cache.
    `void` | `onSpanTouched​(Cache cache, CacheSpan oldSpan, CacheSpan newSpan)` | Called when an existing `CacheSpan` is touched, causing it to be replaced.

- - ### Method Detail

    - #### onSpanAdded

          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`.

    - #### onSpanRemoved

          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`.

    - #### onSpanTouched

          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, `onSpanAdded(Cache, CacheSpan)` and `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.