###The Problem:
How do you create URLs that are short, easy to remember, and unique? Also, how do you store 60M rows so they are easily accessable?
###Getting the data
Get all 5 letter permutations for the letters between a
and z
as well as A
through F
.
###The Source
First, you get all the permutations and write them to disk.
#! /bin/ruby
open('/tmp/random.out', 'w') do |f|
(('a'..'z').to_a + ('A'..'L').to_a).permutation(5) do |p|
f.puts [p.to_a.join, Time.now.to_s(:db), Time.now.to_s(:db)].join(',')
end
end
Why disk? Having a flat file would allow you do do interesting things like pipelining to redis, or LOAD DATA
calls in mysql.
###Storage
Ok, so we got the data, but how do we store it? First though was redis, so we did this:
###Questions
Why did we stop at F
? Franky, we felt like approximately 60 million hashes would get us by for a while. We can always generate more.