Everyone seems to be talking about bloom filters the last couple of years. So last night I implemented one to see what all the rage was about. I'm sure you can find better implementations, but you can find it at https://github.com/chergert/bloom-glib/blob/master/bloom-filter.h.
Also, if you want the opposite of a bloom filter, (direct-mapped cache), you can find that at https://github.com/catch/postal/blob/master/postal/postal-dm-cache.c.
It's likely you are smarter than I and can improve on them, so pull requests accepted.