<p><pre><code> import (
"./utils"
</code></pre>
This is what's known as a relative import, and it's very bad. You want "github.com/johnnye/short/utils", or (better yet) put your base62 stuff in package main, since it's just one function.
Whilst they are nonetheless interesting and worth seeing, there really does seem to be an abundance of really small (30-200 SLoC) projects being posted and reaching the front page recently. I'm just curious because I'd usually consider these sorts of things ~20 minutes' work (plus potentially a more meaningful amount of time writing the documentation). They stand out to me in this sense amongst all the blog posts and stories which almost invariably will have taken a great deal more time and effort to produce. [1]<p>Any thoughts? Indeed any prior discussion?<p>[1]: Not to say that this isn't a nice idea. :)
Very cool. If you have a recent enough version of Redis, you may want to move away from doing the lookup using KEYS and move to SCAN (<a href="http://redis.io/commands/scan" rel="nofollow">http://redis.io/commands/scan</a>). KEYS will work for a while, but with a large enough DB it can become a very slow operation so it's not typically recommended for a production system.<p>Also, just curious, I see that the original url is encoded in the key, so the key is "<short>||<original>". Since the key is already a hash, it seems that you could eliminate having to scan over every key in Redis by making each key be only "<short>" and having an additional field in the hash for "original". Then a lookup becomes simply an HGETALL (if you need to get the "count" field, otherwise just an HGET for the "original" field). I might be missing something though! </armchair programming>