cacheMan
cacheMan

Reputation: 1

memcached, business or data?

Is the cache part of the business or data layer in a simple LAMP stack?

Upvotes: 0

Views: 185

Answers (3)

Siddharth
Siddharth

Reputation: 9574

Memcached sits between a database and webserver. Its a cache, but more importantly its a explicit cache. So things dont get on it on its own. You have to "put" and "get" from it. The biggest advantage is, that it is close to 10 times faster than a database. And if you fetch data from memcached, you wont need to make a sql call, thus saving your database some cycles to do something more important.

So a book catalog website is ideal candidate 80% reads and 20% writes. For more information <here>.

Upvotes: 0

bobince
bobince

Reputation: 536349

memcached is not part of a simple LAMP stack. The basic LAMP app takes its data directly from the database and templates it into the view. The simple application (and even many complicated ones) don't need any more than that.

You add memcached to an application because you've got data that is too slow to compute to do it all live on-the-fly. Whilst certainly memcache counts as being in the data layer, when you are relying on memcache you lose the consistency of a database server, which means you are usually going to need to include some application-specific rules for how long data is cached based on the business logic of your app. So sure, it impinges on the business layer. And if the stuff you're caching is pre-populated views (eg HTML), then it's touching the presentation layer too.

This wide-ranging and not-easily-encapsulated nature is why you shouldn't introduce memcache to an application until you really need to. Don't assume that it's a necessary foundation for performance; remember your database also has table and query caches you may be able to leverage without having to give up consistency and add cache expiry complexity.

Upvotes: 2

Jahan Zinedine
Jahan Zinedine

Reputation: 14874

It's cross cutting concern that may be applied to every piece of data in Business, Data or any other Layer that contains and works with data.

Upvotes: 2

Related Questions