Skip to content

persistent_term: Introduce has_key/1 function #10533

@Benjamin-Philip

Description

@Benjamin-Philip

There is currently no way to quickly check if a key exists in persistent term. The closest you can get is the following function:

has_key(Key) ->
    try
        persistent_term:get(Key),
        true
    catch
        error:badarg ->
            false
    end.

This is clunky and not performant, especially given that is such a trivial function.

Originally suggested by @josevalim and approved by @jhogberg.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions