luminus-framework/ring-ttl-session

Name: ring-ttl-session

Owner: luminus-framework

Description: Provides an implementation of an in-memory ring SessionStore with TTL.

Created: 2016-04-01 23:07:12.0

Updated: 2017-09-24 02:17:33.0

Pushed: 2017-03-30 15:21:36.0

Homepage: null

Size: 20

Language: Clojure

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

ring-ttl-session

travis-status

A session storage that stores session data in-memory with a time-to-live (TTL). It's very similar to ring.middleware.session.memory, but it may use expiring-map (default) or core.cache instead of a Clojure's native map.

Installation

Clojars Project

Usage

The difference from the Ring's native in-memory session store is minimal.

uire '[ring.middleware.session :refer [wrap-session]]
     '[ring-ttl-session.core :refer [ttl-memory-store]])

 app
 Using the default implementation, expiring-map.
rap-session handler {:store (ttl-memory-store (* 60 30))}))

sing core.cache
ttl-memory-store (* 60 30) :core-cache)

The argument of ttl-memory-store is the expiration time given in seconds (the example's session expires in 30 minutes). At least for now, it's recommended to use the default implementation (expiring-map) because of it's low performance overhead when compared with the bare in-memory session store (check the ring-ttl-session.performance namespace or this issue for details).

Listeners

Another interesting feature of expiring-map, the default implementation, is the support for listeners.

-memory-store (* 60 30) {:listeners [(fn [k v] (println k v))]})

Other supported features and options can be checked in the project's page.

License

Copyright © 2015 Andre Boechat

Distributed under the Eclipse Public License, the same as Clojure.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.