                        total-item-bytes])
 
 
-(defn statistics [& {:keys [service namespace]}]
-  (let [service (get-memcache-service :service service :namespace namespace)
-        stats (.getStatistics service)]
+(defn statistics [& {:keys [namespace]}]
+  (let [stats (.getStatistics (get-memcache-service :namespace namespace))]
     (Statistics. (.getBytesReturnedForHits stats)
                  (.getHitCount stats)
                  (.getItemCount stats)


(defn get
  "If (sequential? key), returns values as a map."
  [key & {:keys [service namespace]}]
  (let [service (get-memcache-service :service service :namespace namespace)]
    (if (sequential? key)
        (into {} (.getAll service key))
        (.get service key))))


(defn put [key value & {:keys [service namespace expiration policy]
                        :or {policy :always}}]
  (let [service (get-memcache-service :service service :namespace namespace)
        policy (*policy-type-map* policy)]
    (.put service key value expiration policy)))


(defn put-map [values & {:keys [service namespace expiration policy]
                         :or {policy :always}}]
  (let [service (get-memcache-service :service service :namespace namespace)
        policy (*policy-type-map* policy)]
    (.putAll service values expiration policy)))


(defn increment
  "If (sequential? key), increment each key by the delta."
  [key delta & {:keys [service namespace initial]}]
  (let [service (get-memcache-service :service service :namespace namespace)]
    (if initial
        (if (sequential? key)
            (.incrementAll service key delta (long initial))

   :replace-only MemcacheService$SetPolicy/REPLACE_ONLY_IF_PRESENT})


(defn get-memcache-service [& {:keys [namespace]}]
  (if (nil? namespace)
      (do (when (nil? @*memcache-service*)
            (reset! *memcache-service* (MemcacheServiceFactory/getMemcacheService)))
          @*memcache-service*)
      (let [s (@*namespaced-memcache-services* namespace)]
        (if-not (nil? s)
            s
            ((swap! *namespaced-memcache-services* assoc
                    namespace (MemcacheServiceFactory/getMemcacheService namespace))
             namespace)))))


(defrecord Statistics [bytes-returned-for-hits
