I'm writing a PHP function that would use a table of sorts to look up which DB shard the application should go to, based on the datestamp I have.
The shard configuration is something like this (pseudo-code): the first column is the date of the event I'm looking for and the 2nd is the shard the event resides in.
pre-2008 -> shard1
2008-2009 -> shard2
2009_01-2009_06 -> shard3
2009_07 -> shard4
2009_08 -> shard5
2009_09 and up -> shard6
As you can see, the configuration I want is pretty flexible - it can take any date range, however small or big and map to a shard.
I am looking for the quickest way to do a lookup based on a given date.
For example, if my date is 2009-05-02, the shard I am after is shard3. If the date is 2007-08-01, then it's shard1.
Bonus points for actual PHP code, as the application is in PHP.
Thank you.