Created
February 26, 2011 10:58
-
-
Save ggilder/845107 to your computer and use it in GitHub Desktop.
Random thoughts as I try to get memcached, sinatra, and heroku to play nice
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sinatra-memcached doesn't work with heroku | |
because memcache-client doesn't work with heroku | |
okay, let's rewrite sinatra-memcached to work with dalli, heroku's recommended memcached client | |
hmm, dalli isn't working on my local install so i can't really test it | |
why is it failing to connect to localhost? | |
hmm, dalli requires memcached 1.4+, let's make sure i'm running that | |
huh, 1.2.8, that's weird because i just installed memcached | |
`brew info memcached` says it should be in /usr/local/bin, right... | |
and yet `which memcached` says /usr/bin. uh... wtf | |
ok, let's just symlink the new memcached into /usr/bin, why the fuck not | |
oh wow, everything magically works. special... | |
now if i could just port this "all_keys" method that's monkey patched onto memcached in sinatra-memcached | |
hmm, i can't get the extra options on stats that it does | |
maybe i can monkey patch that | |
looks like i have to send a private method call to the server object, ugh | |
hmm, so that all_keys method relies on some pretty deprecated cachedump shit | |
maybe i should just remove the one method that uses that... why would you need to expire by regexp anyway? or something | |
oh yes, and all the other calls that are using the silly deprecated syntax, right... like you know, set, or [] | |
huh yeah, that seems to do the trick | |
let's see, logging correctly... set, get, get, get, set, get, get, get... yup expiry's working | |
fuck yeah push to heroku DONE | |
no wait tweet about it now DONE | |
https://github.com/ggilder/muni_dashboard/blob/master/lib/support/sinatra-dalli.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, fairly simple - I'm actually using Dalli::Client.new in the "sinatra-dalli" adapter I put together:
https://github.com/ggilder/muni_dashboard/blob/master/lib/support/sinatra-dalli.rb
You can also manually set the configuration variable for the cache client, so you could use something other than a Dalli::Client instance (or manually create a Dalli::Client instance) as long as it responds to the same methods that are used here.
I might tidy that file up a bit and package it as a gem, and maybe include compatibility with the basic Memcached library if I'm feeling ambitious. ;)