Query cache: re-use compiled functions for queries.

Caches the 128 most recently used query ASTs and their corresponding
compiled functions. ~240x speedup, massive reduction in GC pressure
under high query load. NBD. Fixes #312.