Update dependencies, adapt to new core.cache and Ragtime APIs
This commit is contained in:
parent
ba00ba27a5
commit
386f06da8c
4 changed files with 23 additions and 152 deletions
39
project.clj
39
project.clj
|
|
@ -4,8 +4,8 @@
|
||||||
:min-lein-version "2.5.1"
|
:min-lein-version "2.5.1"
|
||||||
:license {:name "Eclipse Public License"
|
:license {:name "Eclipse Public License"
|
||||||
:url "http://www.eclipse.org/legal/epl-v10.html"}
|
:url "http://www.eclipse.org/legal/epl-v10.html"}
|
||||||
:dependencies [[org.clojure/clojure "1.8.0"]
|
:dependencies [[org.clojure/clojure "1.9.0"]
|
||||||
[org.mongodb/mongodb-driver "3.8.0"]
|
[org.mongodb/mongodb-driver "3.9.1"]
|
||||||
[clojurewerkz/support "1.1.0"]]
|
[clojurewerkz/support "1.1.0"]]
|
||||||
:test-selectors {:default (fn [m]
|
:test-selectors {:default (fn [m]
|
||||||
(and (not (:performance m))
|
(and (not (:performance m))
|
||||||
|
|
@ -31,31 +31,28 @@
|
||||||
:mailing-list {:name "clojure-mongodb"
|
:mailing-list {:name "clojure-mongodb"
|
||||||
:archive "https://groups.google.com/group/clojure-mongodb"
|
:archive "https://groups.google.com/group/clojure-mongodb"
|
||||||
:post "clojure-mongodb@googlegroups.com"}
|
:post "clojure-mongodb@googlegroups.com"}
|
||||||
:profiles {:dj02x {:dependencies [[org.clojure/data.json "0.2.6" :exclusions [org.clojure/clojure]]]}
|
:profiles {:1.8 {:dependencies [[org.clojure/clojure "1.8.0"]]}
|
||||||
:1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]}
|
:master {:dependencies [[org.clojure/clojure "1.10.0-master-SNAPSHOT"]]}
|
||||||
:1.7 {:dependencies [[org.clojure/clojure "1.7.0"]]}
|
|
||||||
:1.9 {:dependencies [[org.clojure/clojure "1.9.0-alpha13"]]}
|
|
||||||
:master {:dependencies [[org.clojure/clojure "1.9.0-master-SNAPSHOT"]]}
|
|
||||||
:dev {:resource-paths ["test/resources"]
|
:dev {:resource-paths ["test/resources"]
|
||||||
:dependencies [[clj-time "0.8.0" :exclusions [org.clojure/clojure]]
|
:dependencies [[clj-time "0.15.1" :exclusions [org.clojure/clojure]]
|
||||||
[cheshire "5.5.0" :exclusions [org.clojure/clojure]]
|
[cheshire "5.8.1" :exclusions [org.clojure/clojure]]
|
||||||
[org.clojure/data.json "0.2.5" :exclusions [org.clojure/clojure]]
|
[org.clojure/data.json "0.2.6" :exclusions [org.clojure/clojure]]
|
||||||
[org.clojure/tools.cli "0.3.1" :exclusions [org.clojure/clojure]]
|
[org.clojure/tools.cli "0.4.1" :exclusions [org.clojure/clojure]]
|
||||||
[org.clojure/core.cache "0.6.3" :exclusions [org.clojure/clojure]]
|
[org.clojure/core.cache "0.7.1" :exclusions [org.clojure/clojure]]
|
||||||
[ring/ring-core "1.3.0" :exclusions [org.clojure/clojure]]
|
[ring/ring-core "1.7.1" :exclusions [org.clojure/clojure]]
|
||||||
[com.novemberain/validateur "2.4.2" :exclusions [org.clojure/clojure]]
|
[com.novemberain/validateur "2.6.0" :exclusions [org.clojure/clojure]]
|
||||||
[ch.qos.logback/logback-classic "1.1.3" :exclusions [org.slf4j/slf4j-api]]
|
[ch.qos.logback/logback-classic "1.2.3" :exclusions [org.slf4j/slf4j-api]]
|
||||||
[ragtime/ragtime.core "0.3.7" :exclusions [org.clojure/clojure]]]
|
[ragtime/core "0.7.2" :exclusions [org.clojure/clojure]]]
|
||||||
:plugins [[lein-codox "0.9.0"]]
|
:plugins [[lein-codox "0.10.5"]]
|
||||||
:codox {:source-paths ["src/clojure"]
|
:codox {:source-paths ["src/clojure"]
|
||||||
:namespaces [#"^monger\.(?!internal)"]}}
|
:namespaces [#"^monger\.(?!internal)"]}}
|
||||||
;; only clj-time/JodaTime available, used to test monger.joda-time w/o clojure.data.json
|
;; only clj-time/JodaTime available, used to test monger.joda-time w/o clojure.data.json
|
||||||
:dev2 {:resource-paths ["test/resources"]
|
:dev2 {:resource-paths ["test/resources"]
|
||||||
:dependencies [[clj-time "0.8.0" :exclusions [org.clojure/clojure]]]}}
|
:dependencies [[clj-time "0.15.1" :exclusions [org.clojure/clojure]]]}}
|
||||||
:aliases {"all" ["with-profile" "dev:dev,1.6:dev,1.8:dev,dj02x"]}
|
:aliases {"all" ["with-profile" "dev:dev,1.8:dev,master"]}
|
||||||
:repositories {"sonatype" {:url "http://oss.sonatype.org/content/repositories/releases"
|
:repositories {"sonatype" {:url "https://oss.sonatype.org/content/repositories/releases"
|
||||||
:snapshots false
|
:snapshots false
|
||||||
:releases {:checksum :fail :update :always}}
|
:releases {:checksum :fail :update :always}}
|
||||||
"sonatype-snapshots" {:url "http://oss.sonatype.org/content/repositories/snapshots"
|
"sonatype-snapshots" {:url "https://oss.sonatype.org/content/repositories/snapshots"
|
||||||
:snapshots true
|
:snapshots true
|
||||||
:releases {:checksum :fail :update :always}}})
|
:releases {:checksum :fail :update :always}}})
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
;; The APL v2.0:
|
;; The APL v2.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
||||||
;;
|
;;
|
||||||
;; Licensed under the Apache License, Version 2.0 (the "License");
|
;; Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
;; you may not use this file except in compliance with the License.
|
;; you may not use this file except in compliance with the License.
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
;; The EPL v1.0:
|
;; The EPL v1.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
||||||
;; All rights reserved.
|
;; All rights reserved.
|
||||||
;;
|
;;
|
||||||
;; This program and the accompanying materials are made available under the terms of
|
;; This program and the accompanying materials are made available under the terms of
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
(ns monger.ragtime
|
(ns monger.ragtime
|
||||||
"Ragtime integration"
|
"Ragtime integration"
|
||||||
(:refer-clojure :exclude [find sort])
|
(:refer-clojure :exclude [find sort])
|
||||||
(:require [ragtime.core :as ragtime]
|
(:require [ragtime.protocols :as proto]
|
||||||
[monger.core :as mg]
|
[monger.core :as mg]
|
||||||
[monger.collection :as mc]
|
[monger.collection :as mc]
|
||||||
[monger.query :refer [with-collection find sort]])
|
[monger.query :refer [with-collection find sort]])
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
|
|
||||||
|
|
||||||
(extend-type com.mongodb.DB
|
(extend-type com.mongodb.DB
|
||||||
ragtime/Migratable
|
proto/DataStore
|
||||||
(add-migration-id [db id]
|
(add-migration-id [db id]
|
||||||
(mc/insert db migrations-collection {:_id id :created_at (Date.)} WriteConcern/FSYNC_SAFE))
|
(mc/insert db migrations-collection {:_id id :created_at (Date.)} WriteConcern/FSYNC_SAFE))
|
||||||
(remove-migration-id [db id]
|
(remove-migration-id [db id]
|
||||||
|
|
|
||||||
|
|
@ -1,126 +0,0 @@
|
||||||
(ns monger.test.cache-test
|
|
||||||
(:require [monger.core :as mg]
|
|
||||||
[monger.collection :as mc]
|
|
||||||
[clojure.core.cache :refer :all]
|
|
||||||
[clojure.test :refer :all]
|
|
||||||
[monger.cache :refer :all])
|
|
||||||
(:import [clojure.core.cache BasicCache FIFOCache LRUCache TTLCache]
|
|
||||||
java.util.UUID))
|
|
||||||
|
|
||||||
;;
|
|
||||||
;; Playground/Tests. These were necessary because clojure.core.cache has
|
|
||||||
;; little documentation, incomplete test suite and
|
|
||||||
;; slightly non-standard (although necessary to support all those cache variations)
|
|
||||||
;; cache operations protocol.
|
|
||||||
;;
|
|
||||||
;; This is by no means clear or complete either but it did the job of helping me
|
|
||||||
;; explore the API.
|
|
||||||
|
|
||||||
(deftest ^{:cache true}
|
|
||||||
test-has?-with-basic-cache
|
|
||||||
(testing "that has? returns false for misses"
|
|
||||||
(let [c (BasicCache. {})]
|
|
||||||
(are [v] (is (false? (has? c v)))
|
|
||||||
:missing-key
|
|
||||||
"missing-key"
|
|
||||||
(gensym "missing-key"))))
|
|
||||||
(testing "that has? returns true for hits"
|
|
||||||
(let [c (BasicCache. {:skey "Value" :lkey (Long/valueOf 10000) "kkey" :keyword})]
|
|
||||||
(are [v] (is (has? c v))
|
|
||||||
:skey
|
|
||||||
:lkey
|
|
||||||
"kkey"))))
|
|
||||||
|
|
||||||
|
|
||||||
(deftest ^{:cache true}
|
|
||||||
test-lookup-with-basic-cache
|
|
||||||
(testing "that lookup returns nil for misses"
|
|
||||||
(let [c (BasicCache. {})]
|
|
||||||
(are [v] (is (nil? (lookup c v)))
|
|
||||||
:missing-key
|
|
||||||
"missing-key"
|
|
||||||
(gensym "missing-key"))))
|
|
||||||
(testing "that lookup returns cached values for hits"
|
|
||||||
(let [l (Long/valueOf 10000)
|
|
||||||
c (BasicCache. {:skey "Value" :lkey l "kkey" :keyword})]
|
|
||||||
(are [v k] (is (= v (lookup c k)))
|
|
||||||
"Value" :skey
|
|
||||||
l :lkey
|
|
||||||
:keyword "kkey"))))
|
|
||||||
|
|
||||||
(deftest ^{:cache true}
|
|
||||||
test-evict-with-basic-cache
|
|
||||||
(testing "that evict has no effect for keys that do not exist"
|
|
||||||
(let [c (atom (BasicCache. {:a 1 :b 2}))]
|
|
||||||
(swap! c evict :missing-key)
|
|
||||||
(is (has? @c :a))
|
|
||||||
(is (has? @c :b))))
|
|
||||||
(testing "that evict removes keys that did exist"
|
|
||||||
(let [c (atom (BasicCache. {:skey "Value" "kkey" :keyword}))]
|
|
||||||
(is (has? @c :skey))
|
|
||||||
(is (= "Value" (lookup @c :skey)))
|
|
||||||
(swap! c evict :skey)
|
|
||||||
(is (not (has? @c :skey)))
|
|
||||||
(is (= nil (lookup @c :skey)))
|
|
||||||
(is (has? @c "kkey"))
|
|
||||||
(is (= :keyword (lookup @c "kkey"))))))
|
|
||||||
|
|
||||||
(deftest ^{:cache true}
|
|
||||||
test-seed-with-basic-cache
|
|
||||||
(testing "that seed returns a new value"
|
|
||||||
(let [c (atom (BasicCache. {}))]
|
|
||||||
(swap! c seed {:a 1 :b "b" "c" :d})
|
|
||||||
(are [k v] (do
|
|
||||||
(is (has? @c k))
|
|
||||||
(is (= v (lookup @c k))))
|
|
||||||
:a 1
|
|
||||||
:b "b"
|
|
||||||
"c" :d))))
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
|
||||||
;; Tests
|
|
||||||
;;
|
|
||||||
|
|
||||||
(let [conn (mg/connect)
|
|
||||||
db (mg/get-db conn "monger-test")]
|
|
||||||
(use-fixtures :each (fn [f]
|
|
||||||
(mc/remove db "basic_monger_cache_entries")
|
|
||||||
(f)
|
|
||||||
(mc/remove db "basic_monger_cache_entries")))
|
|
||||||
|
|
||||||
|
|
||||||
(deftest ^{:cache true}
|
|
||||||
test-has?-with-basic-monger-cache
|
|
||||||
(testing "that has? returns false for misses"
|
|
||||||
(let [coll "basic_monger_cache_entries"
|
|
||||||
c (basic-monger-cache-factory db coll)]
|
|
||||||
(is (not (has? c (str (UUID/randomUUID)))))
|
|
||||||
(is (not (has? c (str (UUID/randomUUID)))))))
|
|
||||||
(testing "that has? returns true for hits"
|
|
||||||
(let [coll "basic_monger_cache_entries"
|
|
||||||
c (basic-monger-cache-factory db coll {"a" 1 "b" "cache" "c" 3/4})]
|
|
||||||
(is (has? c "a"))
|
|
||||||
(is (has? c "b"))
|
|
||||||
(is (has? c "c"))
|
|
||||||
(is (not (has? c "d"))))))
|
|
||||||
|
|
||||||
|
|
||||||
(deftest ^{:cache true}
|
|
||||||
test-lookup-with-basic-monger-cache
|
|
||||||
(testing "that lookup returns nil for misses"
|
|
||||||
(let [coll "basic_monger_cache_entries"
|
|
||||||
c (basic-monger-cache-factory db coll)]
|
|
||||||
(are [v] (is (nil? (lookup c v)))
|
|
||||||
:missing-key
|
|
||||||
"missing-key"
|
|
||||||
(gensym "missing-key"))))
|
|
||||||
(testing "that lookup returns cached values for hits"
|
|
||||||
(let [l (Long/valueOf 10000)
|
|
||||||
coll "basic_monger_cache_entries"
|
|
||||||
c (basic-monger-cache-factory db coll {:skey "Value" :lkey l "kkey" :keyword})]
|
|
||||||
(are [v k] (is (= v (lookup c k)))
|
|
||||||
"Value" :skey
|
|
||||||
l :lkey
|
|
||||||
"keyword" "kkey")))))
|
|
||||||
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
(:require [monger.core :as mg]
|
(:require [monger.core :as mg]
|
||||||
[monger.collection :as mc]
|
[monger.collection :as mc]
|
||||||
monger.ragtime
|
monger.ragtime
|
||||||
[ragtime.core :refer :all]
|
[ragtime.protocols :refer :all]
|
||||||
[clojure.test :refer :all]))
|
[clojure.test :refer :all]))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue