Skip to content

Instantly share code, notes, and snippets.

@eagletmt
Created December 13, 2015 04:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eagletmt/31b5bad78238b64279bb to your computer and use it in GitHub Desktop.
Save eagletmt/31b5bad78238b64279bb to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'dalli'
dalli = Dalli::Client.new('127.0.0.1:11211')
dalli.set('valid_ttl', 'value', 100)
p dalli.get('valid_ttl') # "value"
dalli.set('invalid_ttl', 'value', 'Invalid TTL')
p dalli.get('invalid_ttl') # "No server available" error
/home/eagletmt/.ghq/github.com/mperham/dalli/lib/dalli/ring.rb:45:in `server_for_key': No server available (Dalli::RingError)
from /home/eagletmt/.ghq/github.com/mperham/dalli/lib/dalli/client.rb:349:in `perform'
from /home/eagletmt/.ghq/github.com/mperham/dalli/lib/dalli/client.rb:123:in `set'
from pr547.rb:8:in `<main>'
"value"
E, [2015-12-13T13:46:22.584782 #24648] ERROR -- : Unexpected exception during Dalli request: ArgumentError: comparison of String with 2592000 failed
E, [2015-12-13T13:46:22.584871 #24648] ERROR -- : /home/eagletmt/.ghq/github.com/mperham/dalli/lib/dalli/server.rb:487:in `>'
/home/eagletmt/.ghq/github.com/mperham/dalli/lib/dalli/server.rb:487:in `sanitize_ttl'
/home/eagletmt/.ghq/github.com/mperham/dalli/lib/dalli/server.rb:287:in `set'
/home/eagletmt/.ghq/github.com/mperham/dalli/lib/dalli/server.rb:67:in `request'
/home/eagletmt/.ghq/github.com/mperham/dalli/lib/dalli/options.rb:18:in `block in request'
/usr/lib/ruby/2.3.0/monitor.rb:213:in `mon_synchronize'
/home/eagletmt/.ghq/github.com/mperham/dalli/lib/dalli/options.rb:17:in `request'
/home/eagletmt/.ghq/github.com/mperham/dalli/lib/dalli/client.rb:350:in `perform'
/home/eagletmt/.ghq/github.com/mperham/dalli/lib/dalli/client.rb:123:in `set'
pr547.rb:8:in `<main>'
W, [2015-12-13T13:46:22.584941 #24648] WARN -- : 127.0.0.1:11211 is down
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment