Skip to main content
ubuntuask.com

Back to all posts

How to Use ETS (Erlang Term Storage) For Data Storage?

Published on
4 min read
How to Use ETS (Erlang Term Storage) For Data Storage? image

Best Tools to Use ETS for Data Storage to Buy in November 2025

1 Festool 576339 6-Inch Random Orbital Sander ETS EC150/5 EQ-Plus

Festool 576339 6-Inch Random Orbital Sander ETS EC150/5 EQ-Plus

  • STEPLESS SPEED CONTROL FOR CONSISTENT RESULTS UNDER HEAVY LOADS.
  • EFFICIENT 5 MM SANDING STROKE FOR QUICKER MATERIAL REMOVAL.
  • LIGHTWEIGHT DESIGN (2.5 LBS) AND VIBRATION CONTROL FOR LESS FATIGUE.
BUY & SAVE
$645.54
Festool 576339 6-Inch Random Orbital Sander ETS EC150/5 EQ-Plus
2 Festool 576070 Random Orbital Sander ETS 125 REQ-Plus

Festool 576070 Random Orbital Sander ETS 125 REQ-Plus

  • ERGONOMIC DESIGN FOR COMFORT DURING EXTENDED USE IN ANY HAND SIZE.
  • STEP-LESS VARIABLE SPEED FOR PRECISE CONTROL ACROSS VARIOUS APPLICATIONS.
  • JETSTREAM DUST REMOVAL ENSURES CLEANER AIR AND IMPROVES FINISH QUALITY.
BUY & SAVE
$295.74
Festool 576070 Random Orbital Sander ETS 125 REQ-Plus
3 Maigoo 2pack 6" Back-up Sanding Pad Compatible with FES-Tool ETS 150/3 EQ, ETS 150/5 EQ, ETS EC 150/3 EQ,Replace 202460 (6" Hard Sanding Pad)

Maigoo 2pack 6" Back-up Sanding Pad Compatible with FES-Tool ETS 150/3 EQ, ETS 150/5 EQ, ETS EC 150/3 EQ,Replace 202460 (6" Hard Sanding Pad)

  • HIGH COMPATIBILITY: FITS POPULAR MODELS FOR VERSATILE USE-ETS 150 SERIES.
  • DUST-FREE EFFICIENCY: CAPTURES 99% DUST FOR SUPERIOR POLISHING RESULTS.
  • QUICK INSTALLATION: HASSLE-FREE HOOK-AND-LOOP DESIGN FOR EASY PAD CHANGES.
BUY & SAVE
$41.83
Maigoo 2pack 6" Back-up Sanding Pad Compatible with FES-Tool ETS 150/3 EQ, ETS 150/5 EQ, ETS EC 150/3 EQ,Replace 202460 (6" Hard Sanding Pad)
4 EasyTime Beginners Watch Repair Kit: 149PCS Watch Tools with Manual for Link Removal and Battery Replacement - 108 Spring Bars for Strap Adjustment, Gift for DIY Enthusiasts

EasyTime Beginners Watch Repair Kit: 149PCS Watch Tools with Manual for Link Removal and Battery Replacement - 108 Spring Bars for Strap Adjustment, Gift for DIY Enthusiasts

  • EASY WATCH REPAIRS: COMPLETE KIT FOR BEGINNERS SAVES TIME AND MONEY.
  • DURABLE TOOLS: ANTI-CORROSION AND STAINLESS STEEL FOR LONG-LASTING USE.
  • ORGANIZED STORAGE: NEATLY PACKED FOR EFFORTLESS GIFTING AND PORTABILITY.
BUY & SAVE
$16.99
EasyTime Beginners Watch Repair Kit: 149PCS Watch Tools with Manual for Link Removal and Battery Replacement - 108 Spring Bars for Strap Adjustment, Gift for DIY Enthusiasts
5 TOPDON Upgraded AD600S OBD2 Scanner, Diagnostic Tool, ABS SRS Transmission Engine Code Reader, 9 Reset Services Scan Tool, Oil/Brake/BMS/SAS/DPF/TPMS/ETS Reset, Injector Coding, Lifetime Free Update

TOPDON Upgraded AD600S OBD2 Scanner, Diagnostic Tool, ABS SRS Transmission Engine Code Reader, 9 Reset Services Scan Tool, Oil/Brake/BMS/SAS/DPF/TPMS/ETS Reset, Injector Coding, Lifetime Free Update

  • ENHANCED PERFORMANCE: ANDROID 11.0 OS & 32G ROM FOR FASTER DIAGNOSTICS.

  • COMPREHENSIVE DIAGNOSTICS: READS/CODES FOR 4 SYSTEMS & 10,000+ MODELS.

  • COST-SAVING RESET FUNCTIONS: 9 ONE-CLICK RESET OPTIONS FOR EASY MAINTENANCE.

BUY & SAVE
$215.99
TOPDON Upgraded AD600S OBD2 Scanner, Diagnostic Tool, ABS SRS Transmission Engine Code Reader, 9 Reset Services Scan Tool, Oil/Brake/BMS/SAS/DPF/TPMS/ETS Reset, Injector Coding, Lifetime Free Update
6 Weller ETS Long Conical Tip, .4 Mm, Black

Weller ETS Long Conical Tip, .4 Mm, Black

  • COMPACT DESIGN: FITS EASILY IN YOUR POCKET OR BAG!
  • LIGHTWEIGHT AND CONVENIENT FOR ON-THE-GO USE.
  • DURABLE BUILD FOR LASTING PERFORMANCE AND RELIABILITY.
BUY & SAVE
$10.89
Weller ETS Long Conical Tip, .4 Mm, Black
+
ONE MORE?

ETS (Erlang Term Storage) is a mechanism in the Erlang programming language that allows for efficient storage and retrieval of data. It is primarily used for in-memory storage within an Erlang application.

To use ETS for data storage, you first need to create a table using the ets:new/2 function. This function takes two arguments: a table name (an atom) and a set of options (a list of key-value pairs). The options define the type of table and its characteristics, such as whether it is ordered or unordered, protected or private.

Once the table is created, you can insert data into it using the ets:insert/2 or ets:insert_new/2 functions. The former overwrites any existing data with the same key, while the latter only inserts if the key does not already exist. You can use any Erlang term as the key and value pair.

To retrieve data from the table, you can use the ets:lookup/2 function, specifying the table name and the key. It returns a list of matching values or an empty list if there are no matches.

In addition to single-key retrieval, ETS supports more advanced operations such as matching patterns using ets:match/2, iterating over all elements using ets:tab2list/1, and performing aggregations with ets:foldl/3 or ets:foldr/3.

If you need to update or delete data in the table, you can use the ets:update_element/3 or ets:delete/2 functions, respectively. These functions modify the data in place within the table.

Finally, when you are done with a table, you can delete it using the ets:delete/1 function, providing the table name as an argument.

It is important to note that ETS tables are not persisted between different Erlang nodes or system restarts. If you need persistent storage, you would need to implement additional logic to handle that.

ETS provides a fast and efficient way of storing and accessing data in Erlang applications, making it a valuable tool for various use cases such as caching, storing transient data, or maintaining shared state in concurrent systems.

How to retrieve data from an ETS table?

To retrieve data from an ETS (Erlang Term Storage) table in Erlang/OTP, you can use the ets:tab2list/1 function to convert the table into a list of tuples or the ets:tab2list/2 function to convert the table into a list of terms.

Here is an example of how to retrieve data from an ETS table:

  1. Create an ETS table and insert some data into it:

% Create an ordered set table Table = ets:new(my_table, [ordered_set, named_table]).

% Insert data into the table ets:insert(Table, {1, "Alice"}). ets:insert(Table, {2, "Bob"}). ets:insert(Table, {3, "Charlie"}).

  1. Retrieve the data from the ETS table:

% Retrieve the data as a list of tuples DataList = ets:tab2list(Table).

% Print the data io:format("~p~n", [DataList]).

The output will be:

[{1,"Alice"},{2,"Bob"},{3,"Charlie"}]

You can also use ets:tab2list/2 if you want to retrieve only specific fields from the table:

% Retrieve only the names from the table as a list NameList = ets:tab2list(Table, 2).

% Print the names io:format("~p~n", [NameList]).

The output will be:

["Alice","Bob","Charlie"]

Note: Remember to delete the table when you no longer need it using the ets:delete/1 function:

ets:delete(Table).

This will free the memory occupied by the table.

What is the purpose of a bag table in ETS?

In the context of ETS (Educational Testing Service), a bag table is used to conduct the test security procedures during an examination. The purpose of a bag table is to provide a designated area for test takers to securely store their personal belongings, such as bags, backpacks, coats, electronic devices, etc., during the exam. By requiring test takers to place their belongings on a bag table, it helps ensure that they do not take any prohibited items into the testing room that could potentially compromise the integrity and fairness of the test.

How to enable or disable automatic garbage collection in ETS?

By default, Erlang Term Storage (ETS) performs automatic garbage collection. However, you can enable or disable it using the setopts/2 function.

To enable automatic garbage collection in ETS:

ets:setopts(Table, {auto_garbage_collection, true})

To disable automatic garbage collection in ETS:

ets:setopts(Table, {auto_garbage_collection, false})

Here, Table is the identifier of the ETS table you want to modify. By setting the {auto_garbage_collection, true} option, ETS will automatically reclaim memory occupied by removed items. Conversely, setting the {auto_garbage_collection, false} option will disable automatic garbage collection.

Remember to choose the appropriate option based on your specific use case and the impact it may have on memory usage and performance.