kemal-session-mysql v0.2.0
kemal-session-mysql
This is a mysql adaptor for Kemal Session
Installation
Add this to your application's shard.yml
:
dependencies:
kemal-session-mysql:
github: crisward/kemal-session-mysql
Usage
require "kemal"
require "kemal-session-mysql"
require "mysql"
# connect to mysql, update url with your connection info (or perhaps use an ENV var)
connection = DB.open "mysql://root@localhost/test?max_pool_size=50&initial_pool_size=10&max_idle_pool_size=10&retry_attempts=3"
Session.config do |config|
config.cookie_name = "mysql_test"
config.secret = "a_secret"
config.engine = Session::MysqlEngine.new(connection)
config.timeout = Time::Span.new(1, 0, 0)
end
get "/" do
puts "Hello World"
end
post "/sign_in" do |context|
context.session.int("see-it-works", 1)
end
Kemal.run
If you are already using crystal-mysql you can re-use the reference to your connection.
Optional Parameters
Session.config do |config|
config.cookie_name = "mysql_test"
config.secret = "a_secret"
config.engine = Session::MysqlEngine.new(
connection: connection,
sessiontable: "sessions",
cachetime: 5
)
config.timeout = Time::Span.new(1, 0, 0)
end
Param | Description |
---|---|
connection | A Crystal Mysql DB Connection |
sessiontable | Name of the table to use for sessions - defaults to "sessions" |
cachetime | Number of seconds to hold the session data in memory, before re-reading from the database. This is set to 5 seconds by default, set to 0 to hit the db for every request. |
Contributing
- Fork it ( https://github.com/crisward/kemal-session-mysql/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- crisward Cris Ward - creator, maintainer
Repository
kemal-session-mysql
Owner
Statistic
- 7
- 1
- 0
- 0
- 2
- almost 5 years ago
- July 6, 2017
License
MIT License
Links
Synced at
Sat, 21 Dec 2024 18:51:20 GMT
Languages