38 ms·
Your myReadLastIdAndIncrementByOne looks disturbing. Are you sure mnesia:dirty_update_counter/3 doesn't work for your needs? As for ids in mnesia, you aren't
by seiji 19y ago
Your myReadLastIdAndIncrementByOne looks disturbing. Are you sure mnesia:dirty_update_counter/3 doesn't work for your needs?
As for ids in mnesia, you aren't (realistically) at risk of overflowing an integer storage size since you get automatic promotion to bignums. {node(), now()} works fine if you are working in a distributed context and don't need sequential IDs. Also erlang:md5/1, or crypto:sha/1 can give you unique IDs to use over distributed nodes. I wouldn't recommend erlang:phash2 because it only yields 27 bit to 32 bit hashes.
I'm not sure what good term_to_binary would be if you are keeping everything in mnesia.
I would recommend looking into mnesia:dirty_update_counter/3 first and then expand to either {node(), now()} or erlang:md5/1 or crypto:sha/1 if you find updating the counter at distributed nodes is a problem.
- bosky101 19y agothanks for the feedback. yes,im aware of update_counter it works gr8 for incrementing my N. but what if i have a tuple/list/ as the id. shoud i be using mnesia in the first place ? would you use {node(),now()} if you were'nt on a distributed system? how do i notify when i reach a ceiling ? what's the latency in searching only within a specific node ? im sure you can't rule out situations where a one-type-fits-for-all. i just threw couple of different methods out there. thanks for letting me knwo about md5,sha . moreover i wanted to highlight tuples as id's . let's take this very url . ->{ node() , 132377} and simply read 32377 ->{ node() , erlang:md5(132377) } and decrypt while showing? -> how would you store this very url ?