Fix memory leaks and memory corruption in cache backends

See #858

  * Fixed memory corruption in APC/XCache cache backends
  * Fixed memory leaks in Phalcon\Cache\Backend\Apc::queryKeys
  * Optimizations