# CacheSpan

Artifact: [androidx.media3:media3-datasource](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/datasource/cache/CacheSpan.java+class:androidx.media3.datasource.cache.CacheSpan)

*** ** * ** ***


```
@UnstableApi
class CacheSpan : Comparable<CacheSpan!>
```

<br />

*** ** * ** ***

Defines a span of data that may or may not be cached (as indicated by `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan#isCached()`).

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan#CacheSpan(java.lang.String,long,long)(key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Creates a hole CacheSpan which isn't cached, has no last touch timestamp and no file associated. |
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan#CacheSpan(java.lang.String,long,long,long,java.io.File)( key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, lastTouchTimestamp: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, file: https://developer.android.com/reference/java/io/File.html? )` Creates a CacheSpan. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan#compareTo(androidx.media3.datasource.cache.CacheSpan)(another: https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan!)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan#isHoleSpan()()` Returns whether this is a hole `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan#isOpenEnded()()` Returns whether this is an open-ended `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan#toString()()` |

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/java/io/File.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan#file()` The file corresponding to this `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan`, or null if `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan#isCached()` is false. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan#isCached()` Whether the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan` is cached. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan#key()` The cache key that uniquely identifies the resource. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan#lastTouchTimestamp()` The last touch timestamp, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan#isCached()` is false. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan#length()` The length of the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan`, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#LENGTH_UNSET()` if this is an open-ended hole. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan#position()` The position of the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan` in the resource. |

## Public constructors

### CacheSpan

```
CacheSpan(key: String!, position: Long, length: Long)
```

Creates a hole CacheSpan which isn't cached, has no last touch timestamp and no file associated.

| Parameters |
|---|---|
| `key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The cache key that uniquely identifies the resource. |
| `position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The position of the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan` in the resource. |
| `length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The length of the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan`, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#LENGTH_UNSET()` if this is an open-ended hole. |

### CacheSpan

```
CacheSpan(
    key: String!,
    position: Long,
    length: Long,
    lastTouchTimestamp: Long,
    file: File?
)
```

Creates a CacheSpan.

| Parameters |
|---|---|
| `key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The cache key that uniquely identifies the resource. |
| `position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The position of the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan` in the resource. |
| `length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The length of the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan`, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#LENGTH_UNSET()` if this is an open-ended hole. |
| `lastTouchTimestamp: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The last touch timestamp, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan#isCached()` is false. |
| `file: https://developer.android.com/reference/java/io/File.html?` | The file corresponding to this `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan`, or null if it's a hole. |

## Public functions

### compareTo

```
fun compareTo(another: CacheSpan!): Int
```

### isHoleSpan

```
fun isHoleSpan(): Boolean
```

Returns whether this is a hole `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan`.

### isOpenEnded

```
fun isOpenEnded(): Boolean
```

Returns whether this is an open-ended `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan`.

### toString

```
fun toString(): String!
```

## Public properties

### file

```
val file: File?
```

The file corresponding to this `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan`, or null if `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan#isCached()` is false.

### isCached

```
val isCached: Boolean
```

Whether the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan` is cached.

### key

```
val key: String!
```

The cache key that uniquely identifies the resource.

### lastTouchTimestamp

```
val lastTouchTimestamp: Long
```

The last touch timestamp, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan#isCached()` is false.

### length

```
val length: Long
```

The length of the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan`, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#LENGTH_UNSET()` if this is an open-ended hole.

### position

```
val position: Long
```

The position of the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/CacheSpan` in the resource.