# LockFreeObservableCache

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-dynamic-data/cache/struct-lockfreeobservablecache/

**struct** · [`ferroui-dynamic-data`](/docs/0.5.0/api/ferroui-dynamic-data/) · v0.5.0

```rust
struct LockFreeObservableCache<T, K>
```

An observable cache for a single writer (`LockFreeObservableCache<TObject, TKey>`): an edit
delivers its change set as soon as it ends. A clone is a handle to the same cache.

As upstream's, the count and the preview are never notified after the subscription: the
count is the number of items when it is observed, and the preview never has a change set.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/lock_free_observable_cache.rs#L29)

## Members

- [`new`](#function-new)
- [`from_source`](#function-from_source)
- [`edit`](#function-edit)
- [`clear`](#function-clear)

<a id="function-new"></a>

### new

```rust
fn new() -> Self
```

An empty cache (`LockFreeObservableCache()`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/lock_free_observable_cache.rs#L59)

<a id="function-from_source"></a>

### from_source

```rust
fn from_source<C: IChangeSet<T, K>>(source: Rc<dyn IObservable<C>>) -> Self
```

A cache that applies the change sets of `source` (`LockFreeObservableCache(IObservable<IChangeSet>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/lock_free_observable_cache.rs#L70)

<a id="function-edit"></a>

### edit

```rust
fn edit(self: &Self, edit_action: impl FnOnce(&mut dyn ICacheUpdater<T, K>) -> ())
```

Runs an edit, then delivers its changes (`Edit(Action<ICacheUpdater>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/lock_free_observable_cache.rs#L92)

<a id="function-clear"></a>

### clear

```rust
fn clear(self: &Self)
```

Removes every item (`Clear(LockFreeObservableCache)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/lock_free_observable_cache.rs#L103)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`SourceCacheEx<T, K>`](/docs/0.5.0/api/ferroui-dynamic-data/cache/trait-sourcecacheex/)
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `Clone`
- `Default`
- [`IConnectableCache<T, K>`](/docs/0.5.0/api/ferroui-dynamic-data/cache/trait-iconnectablecache/)
- [`IObservableCache<T, K>`](/docs/0.5.0/api/ferroui-dynamic-data/cache/trait-iobservablecache/)
- [`IDisposable`](/docs/0.5.0/api/ferroui-base/reactive/use-idisposable/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
