Misc housekeeping

This commit is contained in:
Peter Taoussanis 2016-06-10 11:18:55 +07:00
parent c6c1e1419e
commit 4e2c24642f
2 changed files with 8 additions and 8 deletions

View file

@ -101,7 +101,7 @@ nippy/stress-data
:uuid (java.util.UUID/randomUUID)
:date (java.util.Date.)
:stress-record (->StressRecord "data")
:stress-record (StressRecord. "data")
;; Serializable
:throwable (Throwable. "Yolo")
@ -152,9 +152,9 @@ There's two default forms of encryption on offer: `:salted` and `:cached`. Each
(nippy/extend-thaw :my-type/foo ; Same type id
[data-input]
(->MyType (.readUTF data-input)))
(MyType. (.readUTF data-input)))
(nippy/thaw (nippy/freeze (->MyType "Joe"))) => #taoensso.nippy.MyType{:data "Joe"}
(nippy/thaw (nippy/freeze (MyType. "Joe"))) => #taoensso.nippy.MyType{:data "Joe"}
```
## Performance

View file

@ -1368,10 +1368,10 @@
(defmacro extend-thaw
"Extends Nippy to support thawing of a custom type with given id:
(extend-thaw :foo/my-type [data-input] ; Keyword id
(->MyType (.readUTF data-input)))
(MyType. (.readUTF data-input)))
;; or
(extend-thaw 1 [data-input] ; Byte id
(->MyType (.readUTF data-input)))"
(MyType. (.readUTF data-input)))"
[custom-type-id [in] & body]
(assert-custom-type-id custom-type-id)
`(do
@ -1389,8 +1389,8 @@
*custom-readers*
(defrecord MyType [data])
(extend-freeze MyType 1 [x out] (.writeUTF out (:data x)))
(extend-thaw 1 [in] (->MyType (.readUTF in)))
(thaw (freeze (->MyType "Joe"))))
(extend-thaw 1 [in] (MyType. (.readUTF in)))
(thaw (freeze (MyType. "Joe"))))
;;;; Stress data
@ -1452,7 +1452,7 @@
:uuid (java.util.UUID/randomUUID)
:date (java.util.Date.)
:stress-record (->StressRecord "data")
:stress-record (StressRecord. "data")
;; Serializable
:throwable (Throwable. "Yolo")