Nearest-neighbor caching for content-match applications