                                            )
 
         result-id-vector   (into [] (map :id results))
+
+        existing-query     (get @cached-queries   query)
         ]
     (do
       (println (str "    " query))
-      (swap! cached-queries assoc  query {
-                                          :records      result-id-vector
-                                          :count        record-count
-                                          }))))
+
+      (if (not existing-query)
+        (swap! cached-queries assoc  query (atom {})))
+
+      (let [the-query        (get @cached-queries   query)
+            ]
+        (swap! the-query assoc  :records      result-id-vector)
+        (swap! the-query assoc  :count        record-count)
+        ))))
 
 
 

                     (println (str "    " query))
                     (println (str "    "))
                     (println (str "    " "Before"))
                     (println (str "    " (get @cached-queries query)))

                     (update-query-in-cache  query)

                     (println (str "    "))
                     (println (str "    " "After"))
                     (println (str "    " (get @cached-queries query)))
                     (println (str "    "))
                     ))))))))


          (println (get @cached-queries  query-key))
          (println "-------------------------------")

           @(get @cached-queries  query-key)
      )


