MongoDB-backed Ring SessionStore
_idMongoDB-backed Ring SessionStore - Session keys are generated with 256-bit CSPRNG randomness (java.security.SecureRandom) and encoded as URL-safe Base64 (43 characters, no padding). - The database stores a SHA-256 hash of the session key as the document `_id`
(make-store adapter & {:keys [read-only? store-session-data?]})Create Ring SessionStore backed by MongoDB.
adapter – an implementation of MongoAdapter.
read-only? – when true, write-session and delete-session are no-ops. Defaults to false
store-session-data? - a function from session data to bool that can, based on the session
data, be used to determine whether the session document should be
written to database at all. For example, if the data contains no
meaningful data, storing the mongo session document can be
prevented by returning false.
Create Ring SessionStore backed by MongoDB.
`adapter` – an implementation of MongoAdapter.
`read-only?` – when true, write-session and delete-session are no-ops. Defaults to false
`store-session-data?` - a function from session data to bool that can, based on the session
data, be used to determine whether the session document should be
written to database at all. For example, if the data contains no
meaningful data, storing the mongo session document can be
prevented by returning false.MongoDB operations adapter
MongoDB operations adapter
(-get-session this id fields)Return a single document map matching the given id, projecting fields. Returns
nil if no document is found. Implementations must dissoc :_id from the MongoDB
document so that the return value matches the SessionResult schema.
Return a single document map matching the given `id`, projecting `fields`. Returns nil if no document is found. Implementations must dissoc `:_id` from the MongoDB document so that the return value matches the `SessionResult` schema.
(-insert-session! this id session)Execute a MongoDB insert with id as the document :_id and session as the other
document data
Execute a MongoDB insert with `id` as the document :_id and `session` as the other document data
(-remove-session! this id)Remove the document with the given id.
Remove the document with the given `id`.
(-update-session! this id session)Execute a MongoDB update with query and $set the session to the document.
Does NOT insert if document does not already exist.
Execute a MongoDB update with `query` and $set the `session` to the document. Does NOT insert if document does not already exist.
(session-id->db-id session-key)Derives the database document _id from the session key by computing its SHA-256 hash
Derives the database document `_id` from the session key by computing its SHA-256 hash
Schema for a session document read from the database.
Schema for a session document read from the database.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |