[Proposal] Registry.unregister_meta/2

48 views
Skip to first unread message

vhf

unread,
Sep 2, 2020, 4:43:22 PM9/2/20
to elixir-lang-core
Hi everyone,

The Registry module has put_meta/3 to store registry metadata but once used to store a key/value there doesn't seem to be a way of removing the key (and its data).

Using put_meta/3 documentation as example:
iex(1)> Registry.start_link(keys: :unique, name: Registry.PutMetaTest)
{:ok, #PID<0.112.0>}
iex(2)> Registry.put_meta(Registry.PutMetaTest, :custom_key, "custom_value")
:ok
iex(3)> Registry.meta(Registry.PutMetaTest, :custom_key)
{:ok, "custom_value"}

I don't think there currently is a way of removing :custom_key and its value:

iex(4)> Registry.unregister(Registry.PutMetaTest, :custom_key)
:ok
iex(5)> Registry.meta(Registry.PutMetaTest, :custom_key)
{:ok, "custom_value"}
iex(6)> Registry.unregister_match(Registry.PutMetaTest, :custom_key, "custom_value")
:ok
iex(7)> Registry.meta(Registry.PutMetaTest, :custom_key)
{:ok, "custom_value"}

What would you think about adding `Registry.unregister_meta/2` (to stay consistent with unregister/2 and unregister_match/4)?

Thanks!

José Valim

unread,
Sep 2, 2020, 4:55:03 PM9/2/20
to elixir-l...@googlegroups.com
A PR for delete_meta is welcome. Unregistered is reserved for processes. Thanks!
Reply all
Reply to author
Forward
0 new messages