Internet Strategy Guide

tekx – memcache and apc

by on May.21, 2010, under php, phptek, tekx

Ben Ramsey (@ramsey) is giving a talk over memcache and APC. You use a cache to reduce the retrieval queries to the database, to reduce the number of requests made to external services, to reduce the time spent computing data and to reduce filesystem access.

Types of caches

  • file system
  • database
  • shared memory
  • RAM disk
  • object cache (memcached and APC)
  • Opcode cache (APC)

Memcached was created for livejournal as a way to solve having to making too many reads to their database. Memcached is a daemon that acts as a simple key/value dictionary.

Who uses it?

  • facebook
  • digg
  • youtube
  • wikipedia
  • moontoast
  • many others

Principles

  • fast asynchronous network I/O
  • NOT a persistent data store
  • It does not provide redundancy
  • data is not replicated across the cluster
  • It doesn’t handle failover

Daemons are not aware of each other. It does not provide authentication so you shouldn’t put themin public areas. They work great on a small and local-area network. A single value can not contain more than 1MB of data. Keys are strings limited to 250 characters.

Simple protocol with storage commands: set,add,replace,append,prepend, cas; retrival: get,gets; deletion: delete;increment/decrements: incr,decr; other: stats,flush_all,version, verbosity, quit.

default port is 11211.

there is a PECL memcache extension, the example is using the PECL memcached example. There is an important distinction. the memcached extention gives you extra information like if the item isn’t found.

Missed the APC part of the talk b/c I’m allergic to something there or coming down with something. Either way, was sneezing up a storm and feeling miserable. Skipped rest of the talk so I wouldn’t be disruptive.

Reblog this post [with Zemanta]
:, ,

3 Trackbacks / Pingbacks for this entry

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!