firebase_pushid v0.1.0 FirebasePushid View Source
Generates a timestamp based id as Firebase does. If same timestamp has already generate id it generates new id sortable.
Link to this section Summary
Functions
Returns a List
with 8 characters based on unix timestamp
example:
iex> 1510647799 |> FirebasePushid.build_ts_char_list
["-", "-", "0", "P", "1", "e", "U", "r"]
Generates Firebase id. It caches with previous timestamp. If same timestamp is stored in the cache it will generate an incremental id in base 64 trying to increment the last possible character. ex: 1) -Kyukibfm7T0jJT_Deyr 2) -Kyukibfm7T0jJT_Deys
Updates last possible index to generate a not colisioning id example:
iex> FirebasePushid.increment_list([1, 2, 3, 4])
[1, 2, 3, 5]
Generates Firebase id with previous cached data (FirebasePushid.Cache) and timestamp
Generates the amount of random numbers all to the max of 63 output example: [41, 7, 5, 22, 40, 5, 35, 42]
Returns the current timestamp in milliseconds
Given a array of numbers until 63, generates a string
Link to this section Functions
Returns a List
with 8 characters based on unix timestamp
example:
iex> 1510647799 |> FirebasePushid.build_ts_char_list
["-", "-", "0", "P", "1", "e", "U", "r"]
Generates Firebase id. It caches with previous timestamp. If same timestamp is stored in the cache it will generate an incremental id in base 64 trying to increment the last possible character. ex: 1) -Kyukibfm7T0jJT_Deyr 2) -Kyukibfm7T0jJT_Deys
If last can not be incremented will update the next ex: 1) -KyukibfiPUIPSaeXo9z 2) -KyukibfiPUIPSaeXoA- 3) -KyukibfiPUIPSaeXoA0 … x) -KyukibfiPUIPSaeXoAz x) -KyukibfiPUIPSaeXoB- x) -KyukibfiPUIPSaeXoB0
Updates last possible index to generate a not colisioning id example:
iex> FirebasePushid.increment_list([1, 2, 3, 4])
[1, 2, 3, 5]
iex> FirebasePushid.increment_list([2, 63])
[3, 0]
Generates Firebase id with previous cached data (FirebasePushid.Cache) and timestamp.
Generates the amount of random numbers all to the max of 63 output example: [41, 7, 5, 22, 40, 5, 35, 42]
example:
iex> FirebasePushid.random_nums(8)
...> |> Enum.count
8
Returns the current timestamp in milliseconds
Given a array of numbers until 63, generates a string
example:
iex> [41, 7, 5, 22, 40, 5, 35, 42]
...> |> FirebasePushid.string_by_nums
"d64Lc4Ye"