You can use a module: https://www.varnish-cache.org/vmod/memcached
This VMOD provides a general purpose memcached client module for Varnish using libmemcached to access memcached servers.
It implements the basic memcached operations of get, set, incr, decr. More features are sure to be added...