I needed to run memcached locally on my Windows PC. These are the steps to making it work on Windows.
(2) Extract the exe to C:\memcached
(3) Open your start menu
(4) In the Search box at the bottom, enter “cmd” – don’t hit enter!
(5) Instead of enter, press Ctrl+Shift + Enter. This should allow you to run the command prompt as the administrator, as long as your Windows user ID is set-up as an admin
(6) use the `cd` command to navigate to get to: C:\memcached
(7) once there, enter: memcached.exe -d install
(8) next enter: memcached.exe -d start
You should now be running a memcached server. To check, open the Windows Task manager and on the Services tab, you should see “memcached”.
I wanted to figure out how much Memcache memory I was using for my Heroku Rails app. After all, how would I know if I need to upgrade otherwise, unless I keep checking the logs for the word ‘miss’.
I found out through this post on Stackoverflow.
From the console (‘heroku run console’ with the Cedar stack), enter
it will provide a bunch of stats, and towards the end you will see bytes.
To learn about caching, I used a few different resources.
The three basic types of caching are:
- page caching – mainly for static pages, it will not work if any filters are applied to the controller of the page (ie authorizations)
- action caching – typically what you’d used to cache a page if they have filters
- fragment caching – allows for caching of blocks of html on a page (if you can’t cache the whole page) or for partials
Since I’m on Heroku, the first place to learn was Heroku’s documentation. It’s important to read the Heroku docs first because some standard Rails functions work differently on Heroku’ platform. Mainly, for page caching (uses different syntax than standard rails) and action caching (mostly dependent on memcache, so you need to set your app up accordingly).
Overview of caching on Heroku
There’s also a Rails Guide on Caching (just remember to ignore page caching part):
However, the most extensive (and useful) one for me was from Adam Hawkins at (especially for fragment caching):
I also needed to learn about sweepers, in order to observe for changes that would impact another controller’s pages. This Stack Overflow post helped me learn to put the sweeper in with the models and to ensure that I updated the correct controller: