 
   Returns updated record."
   [worker job]
-  (let [cache (:cache worker)]
+  (let [cache (:cache worker)
+        aggmap (edn/read-string (:aggmap job))]
     (coll/update *work-collection*
                  {:_id (:_id job)}
                  {"$set" {:status "processed"
                           :finished (now)}})
-    (touch-cache cache (get-in job [:aggmap :query]))))
+    (touch-cache cache (:query aggmap))))
 
 (defn- process-next-job
   [worker]

  "Given a map-reduce job, tells Mongo to perform the job.
   Returns true on success, false on failure."
  [worker job]
  (add-to-cache (:cache worker) (:aggmap job)))

(defn- update-cache
  "Update the query cache to reflect that the map-reduce job is

      (coll/insert-and-return *work-collection* {:_id (:to aggmap)
                                                 :status "unprocessed"
                                                 :created (now)
                                                 :aggmap (pr-str aggmap)})
      (catch MongoException$DuplicateKey e
        (coll/find-map-by-id *work-collection* (:to aggmap))))))

