Elixir ETS key pattern matching

Viewed 1241

I am using ETS to cached a database schema from postegress using ecto here are those examples:

table = :ets.new(:cache_name,[:set, :protected])

and include those registry:

:ets.insert(table,{:first_table,{1}})

:ets.insert(table,{:first_table,{5}})

:ets.insert(table,{:second_table,{1}})

but the second one replace the first one, for that reason i concat the table name and the id to get a unique key :ets.insert(table,{:first_table1,{1}}) for these registry, but at the moment that i want the first registry for the first table i have a problem because i contain the same key for the second and it retreive two registry:

:ets.match_object(table,{:"_",{1}})

how can i specify to ETS that if the key contains the table_name retreive these registry?

1 Answers
Related