Emphemeral and immutable

When storing data, most data have a lifecycle - it created, managed and eventually deleted through operation of the application or script that use it. There are however to kinds of data storage which is slightly different, which developers should know about as they may be nice patterns to know and use when applicable.

Emphemeral data

The first data storage is emphemeral data. This kind of data will eventually automatically be deleted. In most cases the data is stored shortly - an hour, a day or a week - but there isn’t any fixed rule which define when the data disappear - just that it does by itself without any explicit cleanup or pruning from the developer (or user).

This kind of data is mostly use in cache systems - where the temporary data is used to accellerate access to the data, but it’s also used in messaging systems and other use cases where the long term storeage isn’t applicable due to privacy, storeage savings or just that it isn’t worth saving due to the nature of the data.

Immutable data

The second kind is less know and called immutable. This kind of data only support creating and reading, but now changing nor deleting. You can naturally delete the data by wiping the storeage medium (like formating the disk) but the intention is it’s a pure write-once storeage.

When updating records in an immutable storeage - you would write a new copy and update a serialnumber

  • or more likely a timestamp - to let you know which version is the newest and which previous versions have existed.