Redis Session for Ruby

I'ved created a standalone session system based on Redis database.
This session system was not build only for web in mind, but also for non web based systems.
I for example, use it with Asterisk based programs that I'm writing to clients.

The session lib supports at the moment only few features:

  1. Connect to Unix sockets
  2. Connect to TCP sockets, and changing the port number if needed
  3. Expiring all keys
  4. Expiring specific keys
  5. Changing expiry of a specific key
  6. Checking expiry of a specific key
  7. Saving and restoring Ruby based structures such as hashes, arrays, boolean etc…
  8. Removing keys
  9. Prefix that will be automatically added to each key name (in saving and restoring)

The usage of the system is very simple:

require 'rubygems'
require 'redis_session'
session = Session::SessionClient.new(:prefix => 'add_test') # init the session
session.save('name', { 'name' => 'session'}) # Saving a content. Pure ruby content
restored = session.restore('name') # return to me a pure ruby content
puts restored.inspect
session.remove('name') # delete the key
view raw sessoin.rb hosted with ❤ by GitHub

The current version (0.1.3), does not contain yet any documentation. However it will be added in next version.
The library itself is under the MIT license, and can be downloaded here.

You can create your own gem file. I hope that by the next version, it will be created automatically.

* You must have active Javascript support for wordpress.com and github to view the source code.

כתיבת תגובה

אתר זו עושה שימוש ב-Akismet כדי לסנן תגובות זבל. פרטים נוספים אודות איך המידע מהתגובה שלך יעובד.