                     err = 'postgresql ' + err
                 else
                     dbg("done (concurrent=#{@_concurrent_queries}) -- success")
+                if opts.cache and @_query_cache?
+                    @_query_cache.set(full_query_string, [err, result])
                 opts.cb?(err, result)
         catch e
             # this should never ever happen

            opts.query += " LIMIT #{opts.limit} "

        dbg("query='#{opts.query}'")

        # params can easily be huge, e.g., a blob.  But this may be
        # needed at some point for debugging.

            @_port = 5432
        @_database = opts.database
        @_concurrent_queries = 0
        if opts.cache_expiry and opts.cache_size
            @_query_cache = (new require('expiring-lru-cache'))(size:opts.cache_size, expiry: opts.cache_expiry)
        if opts.connect
            @connect()  # start trying to connect

