I'm trying to come up with an algorithm to hash a string into a specific number of buckets but haven't had any luck coming up with ideas on how to do this?
I have a list of strings like this:
a.jpg
b.htm
c.gif
d.jpg
e.swf
and i would like to run a function to get a number between 1 and 4 based on the string.
e.g. a.jpg would be 3
b.htm would be 2
c.gif would be 1
etc
it needs to be consistent so if i run the function on a.jpg it always returns 3.
this algorithm would be for splitting resources between servers...
e.g. a.jpg would be accessed from server3.mydomain.com
b.htm would be accessed from server2.mydomain.com
etc
Does anyone know how I would go about doing this?
Any advice would be much appreciated!
Cheers
Tim