kemal-session-mysql
Version, currently 0.2.02 versions
- 0.2.0latestJan 15, 2020
- 0.1.0not indexedJan 15, 2020
github.com/crisward/kemal-session-mysql
An Mysql Engine for Kemal-Session
7 stars
0 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
kemal-session-mysql:
github: crisward/kemal-session-mysql
version: ~> 0.2.0Then run:
shards installshard.yml
- Crystal
0.32.1- License
- MIT
- Author
- Cris Ward <cris@duodesign.co.uk>
Dependencies
Runtime Dependencies
- mysql*github: crystal-lang/crystal-mysql
- kemal-session*github: kemalcr/kemal-session
README
# kemal-session-mysql
[](https://travis-ci.org/crisward/kemal-session-mysql)
This is a mysql adaptor for [Kemal Session](https://github.com/kemalcr/kemal-session)
## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
kemal-session-mysql:
github: crisward/kemal-session-mysql
```
## Usage
```crystal
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
1. Fork it ( https://github.com/crisward/kemal-session-mysql/fork )
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create a new Pull Request
## Contributors
- [crisward](https://github.com/crisward) Cris Ward - creator, maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.2.0- Tagged
- Jan 15, 2020
- Commit
02420b8d9410- Crystal
0.32.1- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/crisward/kemal-session-mysql
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 14, 2026
- Synced
- Aug 14, 2026
- Versions
- 2