Rewrite of the file based cache backend

Fixes for trac tickets #20536, #15825 and #15806

 * Safer for use in multiprocess environments
 * Better random culling, only counts and deletes real cache files
 * Cache files use less disk space
 * Safer clearing, only delete actual cache files, does not delete the entire cache dir.
 * Less error swallowing, I've only handled the errors I could reproduce

Backwards incompatible changes:

Got rid of the nested directories. Cache files can now be created atomically (by writing to a temp file and then renaming). I cannot find a compelling reason to keep using the nested directories. Only FAT32 seems to have a directory entries limit, but the default MAX_ENTRIES of 300 does not reach this limit by far.

gzip the value pickle. This adds some slight CPU overhead on write (no noticeable overhead on read), but makes the cache files smaller, improving disk write/read performance.

Passes all the tests (Linux/py27, test_sqlite settings) and raises no errors on a script I created that uses multiprocessing to do lots of concurrent cache read/writes to the same key.

Performance is about the same as the current FileBasedCache backend.