# uproot.LRUCache

Defined in [uproot.cache](https://github.com/scikit-hep/uproot5/blob/db953cf9827349b3d24eb6742404158c1dfd5481/src/uproot/cache.py) on [line 23](https://github.com/scikit-hep/uproot5/blob/db953cf9827349b3d24eb6742404158c1dfd5481/src/uproot/cache.py#L23).

| **Inheritance order:**                                                                                                                                                                                       |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1. `collections.abc.MutableMapping`<br/>2. `collections.abc.Mapping`<br/>3. `collections.abc.Collection`<br/>4. `collections.abc.Sized`<br/>5. `collections.abc.Iterable`<br/>6. `collections.abc.Container` |

### *class* uproot.cache.LRUCache(limit)

* **Parameters:**
  **limit** (*None* *or* *int*) – Number of objects to allow in the cache before
  evicting the least-recently used. If None, this cache never evicts.

LRUCache is a `MutableMapping` that evicts the least-recently used
objects when the `current` number of objects exceeds the `limit`.

Get and set (or explicitly remove) items with `MutableMapping` syntax:
square bracket subscripting.

LRUCache is thread-safe for all options: getting, setting, deleting,
iterating, listing keys, values, and items.

This cache is insensitive to the size of the objects it stores, and hence
is a better `object_cache` than an `array_cache`  (cf. [uproot.LRUArrayCache](uproot.cache.LRUArrayCache.html.md)).

<a id="uproot-cache-lrucache-sizeof"></a>

## sizeof

#### *classmethod* LRUCache.sizeof(obj)

The “size of” an object in this cache is always exactly 1.

<a id="uproot-cache-lrucache-limit"></a>

## limit

#### LRUCache.limit

Number of objects to allow in the cache before evicting the
least-recently used. If None, this cache never evicts.

<a id="uproot-cache-lrucache-current"></a>

## current

#### LRUCache.current

Current number of items in the cache.

<a id="uproot-cache-lrucache-keys"></a>

## keys

#### LRUCache.keys()

Returns a copy of the keys currently in the cache, in least-recently
used order.

The list ascends from least-recently used to most-recently used: index
`0` is the least-recently used and index `-1` is the most-recently
used.

(Calling this method does not change the order.)

<a id="uproot-cache-lrucache-values"></a>

## values

#### LRUCache.values()

Returns a copy of the values currently in the cache, in least-recently
used order.

The list ascends from least-recently used to most-recently used: index
`0` is the least-recently used and index `-1` is the most-recently
used.

(Calling this method does not change the order.)

<a id="uproot-cache-lrucache-items"></a>

## items

#### LRUCache.items()

Returns a copy of the items currently in the cache, in least-recently
used order.

The list ascends from least-recently used to most-recently used: index
`0` is the least-recently used and index `-1` is the most-recently
used.

(Calling this method does not change the order.)
