fixes PowerDNS/pdns#693

removes number of static variables and makes them class, also optimizes if query cache is disabled.