Permalink
Browse files

Use reify instead of proxy

  • Loading branch information...
1 parent f2ee02d commit a41b96a4a862bb315ab4758bb4c1a872c8b63a75 @apage43 committed Oct 14, 2012
Showing with 17 additions and 17 deletions.
  1. +2 −2 src/cbdrawer/client.clj
  2. +15 −15 src/cbdrawer/transcoders.clj
View
@@ -61,8 +61,8 @@
"Atomically update an item with the result of applying `f` to it,
with a specified transcoder."
[^CouchbaseClient conn key f ^Transcoder transcoder]
- (let [mutation (proxy [CASMutation] []
- (getNewValue [current]
+ (let [mutation (reify CASMutation
+ (getNewValue [_this current]
(f current)))]
(.cas (CASMutator. conn transcoder) key nil 0 mutation)))
@@ -8,34 +8,34 @@
"A spymemcached Transcoder that serializes Clojure datastructures to
JSON, which allows use of Couchbase Views."}
json-transcoder
- (proxy [Transcoder] []
- (asyncDecode [_] false)
- (decode [^CachedData bs] (cheshire/parse-string (String. (.getData bs)) true))
- (encode [o] (CachedData. 0 (.getBytes (cheshire/generate-string o)) CachedData/MAX_SIZE))
- (getMaxSize [] CachedData/MAX_SIZE)))
+ (reify Transcoder
+ (asyncDecode [_this _] false)
+ (decode [_this bs] (cheshire/parse-string (String. (.getData bs)) true))
+ (encode [_this o] (CachedData. 0 (.getBytes (cheshire/generate-string o)) CachedData/MAX_SIZE))
+ (getMaxSize [_this] CachedData/MAX_SIZE)))
(def
^{:doc
"A spymemcached Transcoder that serializes to SMILE, a JSON-compatible compact
binary format. http://wiki.fasterxml.com/SmileFormatSpec"}
smile-transcoder
- (proxy [Transcoder] []
- (asyncDecode [_] false)
- (decode [^CachedData bs] (cheshire/parse-smile (.getData bs) true))
- (encode [o] (CachedData. 0 (cheshire/generate-smile o) CachedData/MAX_SIZE))
- (getMaxSize [] CachedData/MAX_SIZE)))
+ (reify Transcoder
+ (asyncDecode [_this _] false)
+ (decode [_this bs] (cheshire/parse-smile (.getData bs) true))
+ (encode [_this o] (CachedData. 0 (cheshire/generate-smile o) CachedData/MAX_SIZE))
+ (getMaxSize [_this] CachedData/MAX_SIZE)))
(def
^{:doc
"A spymemcached Transcoder that serializes Clojure datastructures.
The default java Serializing transcoder will work for any Clojure type,
but this format is smaller and readable. See edn-format.org"}
clj-transcoder
- (proxy [Transcoder] []
- (asyncDecode [_] false)
- (decode [^CachedData bs] (read-string (String. (.getData bs))))
- (encode [o] (CachedData. 0 (.getBytes (pr-str o)) CachedData/MAX_SIZE))
- (getMaxSize [] CachedData/MAX_SIZE)))
+ (reify Transcoder
+ (asyncDecode [_this _] false)
+ (decode [_this bs] (read-string (String. (.getData bs))))
+ (encode [_this o] (CachedData. 0 (.getBytes (pr-str o)) CachedData/MAX_SIZE))
+ (getMaxSize [_this] CachedData/MAX_SIZE)))
(def ^{:doc "The default spymemcached serializing transcoder"} spy-transcoder
(net.spy.memcached.transcoders.SerializingTranscoder.))

0 comments on commit a41b96a

Please sign in to comment.