Skip to content

Instantly share code, notes, and snippets.

View nateleavitt's full-sized avatar

nateleavitt nateleavitt

View GitHub Profile

Keybase proof

I hereby claim:

  • I am nateleavitt on github.
  • I am nateleavitt (https://keybase.io/nateleavitt) on keybase.
  • I have a public key ASD_Y1JpUCSx4R9b0_DqjAMNGbvnczcpqHxpMAZnRbfaIwo

To claim this, I am signing this object:

require 'memcached'
memcached_config = YAML.load_file("#{Rails.root}/config/memcached.yml")
SESSION_MEMCACHE_CLIENT = Memcached.new(memcached_config['defaults']['servers'],memcached_config['defaults'])
config.cache_store = :libmemcached_store, memcached_config['defaults']['servers']
@nateleavitt
nateleavitt / app_controller
Created January 21, 2011 09:43
cache code
User
def current_user
@current_user ||= Rails.cache.fetch("customerhub:current:user:#{session[:user_id]}:v#{HUB_VERSION}",
:expires_in => 20.minutes) {
User.find(session[:user_id])
}
end
# Will either fetch the current account or return nil if none is found
Account
@nateleavitt
nateleavitt / norm
Created January 21, 2011 09:27
normal output
<10 get customerhub:current:style:infused:v1.7
>10 sending key customerhub:current:style:infused:v1.7
>10 END
<11 set 36f39f650a7e7c40c51cfc36ded6a986 0 0 165
>11 STORED
<10 get customerhub:current:account:infused:v1.7
>10 sending key customerhub:current:account:infused:v1.7
>10 END
<11 get 36f39f650a7e7c40c51cfc36ded6a986
>11 sending key 36f39f650a7e7c40c51cfc36ded6a986
@nateleavitt
nateleavitt / memcached_logs
Created January 21, 2011 07:12
here is some weird output i was getting
<30 new auto-negotiating client connection
30: Client using the ascii protocol
<30 get customerhub:current:account:mastersoflight:v1.7
>30 sending key customerhub:current:account:mastersoflight:v1.7
>30 END
<31 new auto-negotiating client connection
31: Client using the ascii protocol
<31 get 1671a2297858e754a8e24bd2ae9c6161
>31 sending key 1671a2297858e754a8e24bd2ae9c6161
>31 END
/*
Jquery and Rails powered default application.js
Easy Ajax replacement for remote_functions and ajax_form based on class name
All actions will reply to the .js format
Unostrusive, will only works if Javascript enabled, if not, respond to an HTML as a normal link
respond_to do |format|
format.html
format.js {render :layout => false}
end
*/
# Settings specified here will take precedence over those in config/environment.rb
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.action_controller.consider_all_requests_local = false
config.action_controller.perform_caching = true