hashing keys across servers

Paul T pault12345 at yahoo.com
Thu Oct 19 05:31:55 UTC 2006


It is magical bernstien hashing you commented out

http://www.cse.yorku.ca/~oz/hash.html

It is best for short (<=6) english letters keys.

Rgds.Paul.


--- Jed Reynolds <lists at benrey.is-a-geek.net> wrote:

> Since I'm not using a PECL library for PHP, I found
> the phpCA memcache 
> client [ http://phpca.cytherianage.net/memcached/ ]
> and it seems to work 
> alright. I had to dig into it a bit to figure out
> it's "buckets" model 
> for mapping keys across servers. I did have to make
> this modification:
> 
>    // map a text key to an integer that can be
>    // modulated to an index
>    // of a server bucket
>    function _hashfunc ($key)
>    {
>       $hash = 0;
>       // the following hash doesn't work with my
> keys
>       /*
>       for ($i=0; $i<strlen($key); $i++)
>       {
>          $hash = $hash*33 + ord($key[$i]);
>       }
>       */
>       // this has better distribution
>       $hash = crc32( $key );
> 
>       return $hash;
>    }
> 
> 
> Which brings up a question: Is the hash function I
> commented out a 
> pretty common one?
> I understand that hash functions have to be tuned to
> the values of the 
> keys they use. So is my modification a pretty common
> one? Because I was 
> finding that this has function modulated all my keys
> to one index.
> 
> Jed
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the memcached mailing list