# Replacing all ets table content atomically

**URL:** <https://forum.elixirforum.com/t/replacing-all-ets-table-content-atomically/54852>\
**Category:** Questions\
**Tags:** ets\
**Created:** [March 26, 2023, 8:38pm UTC](https://forum.elixirforum.com/t/replacing-all-ets-table-content-atomically/54852 "2023-03-26T20:38:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thousandsofthem](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/thousandsofthem/32/1030_2.png) [@thousandsofthem](https://forum.elixirforum.com/u/thousandsofthem)\
**Post date:** [March 26, 2023, 8:38pm UTC](https://forum.elixirforum.com/t/replacing-all-ets-table-content-atomically/54852/1 "2023-03-26T20:38:24Z")

</div>

Can’t find a way to replace whole ets table (i.e. all records) at once.

- There is `tab2list` function, but no `list2tab`.
- `file2tab` crates table, doesn’t update existing one
- Emptying existing table + `insert` leaves the gap in between. insert operation is atomic by itself, but combination of two calls is not

Maybe some smart merging will help, deleting stale records, updating existing records after that, but that’s expensive and feels wrong.

Context: i’m getting list of items from outside every X minutes, and want to cache them, to be used in app

---

<div class="post-metadata">

**Author:** ![cmo](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/cmo/32/19618_2.png) [@cmo](https://forum.elixirforum.com/u/cmo)\
**Post date:** [March 26, 2023, 10:49pm UTC](https://forum.elixirforum.com/t/replacing-all-ets-table-content-atomically/54852/2 "2023-03-26T22:49:27Z")

</div>

Create another table and point to it, then delete the old one, ala generational caching?

---

<div class="post-metadata">

**Author:** ![thousandsofthem](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/thousandsofthem/32/1030_2.png) [@thousandsofthem](https://forum.elixirforum.com/u/thousandsofthem)\
**Post date:** [March 27, 2023, 7:06am UTC](https://forum.elixirforum.com/t/replacing-all-ets-table-content-atomically/54852/3 "2023-03-27T07:06:17Z")

</div>

Thanks, i’ll try this way
