Status message

Maintenant, vous regardez: Caching in drupal 7

Caching in drupal 7

Modules often have to make expensive database queries or calls to remote web services. Rather than
using resources for those operations every time they occur, modules can store a cache of their data into
one of the bins reserved for caching within the Drupal database, where bins are tables in the database.
Standard bins include the following:

cache: This is the generic cache storage bin. This bin is used to store variables ,the theme registry, locale date, a list of simple test, etc.
cache_block: This bin stores the content for various blocks.
cache_bootstrap: This bin stores information used during bootstrap.
cache_field: This bin stores loaded fields for an entity object.
cache_filter: This bin stores filtered pieces of content.
cache_form: This bin stores multistep forms.
cache_image: This bin stores information about in-progress image manipulations.
cache_menu: This bin stores the structure of visible navigation menus per page.
cache_page: This bin stores generated pages for anonymous users. This table is flushed often, whenever a page changes,
at least for every node and comment submission. This is the only bin affected by the page cache settings on the
administrator panel.
cache_path: This bin stores the system paths that have an alias.
cache_update: This bin stores available releases.

In general:
cache stores a copy of the variables table and the database schema and theme registry;
cache_block stores cached copies of blocks;
cache_bootstrap stores information that is used during the bootstrap process;
cache_field stores information about fields;
cache_image stores information about images;
cache_menu stores cached copies of the navigational menus;
cache_filter stores cached copies of each node’s content after it has been parsed by the filter system;
cache_form is used by the form API to avoid form building when possible;
cache_page stores cached copies of pages for anonymous users;
cache_path stores cached URL aliases;
cache_update stores information related to the current version of Drupal and modules used on your site.

It should be noted that the “Page cache” and “Block cache” settings at Configuration -> Performance affect only the
page cache and block cache tables, not the other cache components within Drupal. In other words,
filters, menus, and module settings are always cached.

Let’s take a look at the database structure of the cache table:

  1. mysql> desc cache;
  2. +------------+--------------+------+-----+---------+-------+
  3. | Field | Type | Null | Key | Default | Extra |
  4. +------------+--------------+------+-----+---------+-------+
  5. | cid | varchar(255) | NO | PRI | | |
  6. | data | longblob | YES | | NULL | |
  7. | expire | int(11) | NO | MUL | 0 | |
  8. | created | int(11) | NO | | 0 | |
  9. | serialized | smallint(6) | NO | | 0 | |
  10. +------------+--------------+------+-----+---------+-------+

Module developers looking to take advantage of the cache API have two functions they need to know:
cache_set() and cache_get().

Using the Cache API
1. cache_set() is used for writing data to the cache. The function signature follows:
cache_set($cid, $data, $bin = 'cache', $expire = CACHE_PERMANENT)
And the function parameters are as follows:

  1. • $cid: A unique cache ID string that acts as a key to the data. Colons are used to
  2. delimit the hierarchy of possibilities.
  3. • $bin: The name of the cache bin to store the data in. Valid core values are
  4. 'cache_block', 'cache_bootstrap', 'cache_field', 'cache_filter', 'cache_form',
  5. 'cache_menu', 'cache_page', 'cache_update', or 'cache' for the default cache.
  6. • $data: The data to store in the cache. PHP objects and arrays will be automatically
  7. serialized.
  8. • $expire: The length of time for which the cached data is valid. Possible values are
  9. CACHE_PERMANENT, CACHE_TEMPORARY, or a Unix timestamp. If a Unix timestamp is
  10. given, the data will be treated as if it were marked CACHE_TEMPORARY after the
  11. current time exceeds the Unix timestamp.

A common iteration pattern for cache_set() can be seen in modules/filter/filter.module:

  1. // Store in cache with a minimum expiration time of 1 day.
  2. if ($cache) {
  3. cache_set($cid, $text, 'cache_filter', REQUEST_TIME + (60 * 60 * 24));
  4. }

2.cache_get() is for retrieving the cached data. The function signature follows:
cache_get($cid, $bin = 'cache')
And the function parameters are as follows:

  1. • $cid: This is the cache ID of the data to retrieve.
  2. • $bin: This is the name of the cache bin to store the data in. Valid core values are
  3. 'cache_block', 'cache_bootstrap', 'cache_field', 'cache_filter', 'cache_form',
  4. 'cache_menu', 'cache_page', 'cache_update', or 'cache' for the default cache.

A common pattern for cache_get() can be seen in modules/filter/filter.module.

  1. // Check for a cached version of this piece of text.
  2. if ($cached = cache_get($cid, 'cache_filter')) {
  3. return $cached->data;
  4. }



Pretty section of content. I just stumbled upon your blog

and in accession capital to assert that I acquire actually enjoyed account your blog posts.

Any way I'll be subscribing to your augment and even I achievement you access consistently fast.

Feel free to surf to my web page: free the vbucks

of course like your web-site but you need to test the spelling on quite

a few of your posts. Several of them are rife with spelling

issues and I find it very bothersome to inform the truth on the other hand I will certainly come

again again.


Review my page - Grant canadian pharmacy meds
best canadian mail order pharmacies
canadian pharcharmy online24 prescription drugs without prior prescription
canadian pharmaceuticals for usa sales
most reliable canadian online pharmacies

I'm excited to discover this great site. I wanted to

thank you for ones time just for this wonderful read!! I

definitely loved every bit of it and i also have

you saved as a favorite to look at new information on your web hosting services site.

Hi there, I discovered your website by means of Google even as looking for a comparable

matter, your website came up, it appears to be like

good. I've bookmarked it in my google bookmarks.

Hi there, just turned into alert to your blog thru Google,

and found that it is really informative. I am going to be

careful for brussels. I will be grateful when you proceed

this in future. Lots of people might be benefited out of your writing.


Also visit my homepage - free vbucks generator

I visited various web pages however the audio feature for audio songs

existing at this site is actually superb.

My homepage ... free the vbucks

Good day! I know this is kinda off topic but I was wondering which blog platform are you using for this website?

I'm getting sick and tired of Wordpress because I've had issues with hackers and I'm looking at alternatives for another platform.

I would be fantastic if you could point me in the direction of

a good platform.

Take a look at my website :: free v bucks

Hello to all, since I am actually keen of reading this blog's post to be updated regularly.

It contains pleasant stuff.

Feel free to surf to my website ... free the vbucks canada medications buy
canadian online pharmacies
the best canadian online pharmacies northwest pharmacies online
pharmacy canada reviews
canadian government approved pharmacies canadian pharmacy no prescription
online canadian discount pharmacies
online pharmacy

My programmer is trying to persuade me to move to

.net from PHP. I have always disliked the idea because of the

costs. But he's tryiong none the less. I've been using WordPress on various

websites for about a year and am worried about switching

to another platform. I have heard good things about Is there a way I can import all my wordpress posts into it?

Any kind of help would be greatly appreciated!

My webpage - free vbucks generator

Definitely consider that which you stated. Your favourite justification seemed to be at the internet the simplest thing to keep

in mind of. I say to you, I certainly get irked even as people think about issues that they plainly do not understand about.

You managed to hit the nail upon the top and also outlined out the entire thing with no

need side-effects , other folks could take a signal.

Will likely be back to get more. Thanks

my blog post :: v bucks free generator

You actually make it seem so easy with your presentation but I find this matter to be actually one thing

that I think I would by no means understand.

It kind of feels too complicated and very large for

me. I am taking a look forward in your next submit,

I will attempt to get the hang of it!

Also visit my page: free vbucks canadian prescriptions online serc 24 mg
canadian discount pharmacies in canada
pharmacy times

Fantastic beat ! I would like to apprentice while

you amend your site, how could i subscribe for a blog web

site? The account aided me a acceptable deal. I had been a

little bit acquainted of this your broadcast offered bright clear idea

Feel free to surf to my webpage :: free vbucks generator

When I initially commented I clicked the "Notify me when new comments are added" checkbox and now each time

a comment is added I get several e-mails with the same comment.

Is there any way you can remove me from that service? Appreciate it!

my homepage :: free the vbucks

Hey there! This is my first visit to your blog!

We are a team of volunteers and starting a new initiative in a community in the same

niche. Your blog provided us useful information to work on. You

have done a outstanding job!

Feel free to visit my web site: v bucks free generator

It's not my first time to pay a quick visit this website, i am visiting this

website dailly and take pleasant facts from here everyday.

Here is my web page: v bucks free

Hey there! This is my first comment here so I just wanted to give a quick shout

out and tell you I genuinely enjoy reading your blog posts.

Can you suggest any other blogs/websites/forums that cover the same topics?

Thank you!

My web-site - magazin pescuit

I don't even know how I ended up here, but I thought this post was great.

I don't know who you are but certainly you are going to a famous blogger if you aren't already ;) Cheers!

Here is my web blog ... free vbucks generator

It's awesome to pay a quick visit this website and reading

the views of all colleagues on the topic of this piece of writing, while

I am also keen of getting knowledge.

Feel free to surf to my website :: free v bucks

fantastic publish, very informative. I wonder why the opposite experts of

this sector don't understand this. You must continue your writing.

I'm sure, you have a great readers' base already!

Feel free to visit my website: v bucks free

What's up, I would like to subscribe for this weblog to get latest updates,

so where can i do it please help out.

Also visit my web-site ... v bucks free generator online canadian discount pharmacies
trust pharmacy canada reviews
canadian pharmacy cialis

I've read several just right stuff here. Definitely worth bookmarking

for revisiting. I wonder how much effort you set to create any such great informative web site.

My site; free v bucks

It's an remarkable paragraph in support of all the internet visitors; they will obtain benefit from it I am


Here is my web site free vbucks north west pharmacies canada
canadian drug store
north west pharmacies canada

Hey there! Do you use Twitter? I'd like to follow you if that would be ok.

I'm undoubtedly enjoying your blog and look forward to new updates.

Feel free to visit my blog post :: free v bucks canada medication
canada pharmacies online prescriptions
are canadian online pharmacies safe

Wow! This blog looks just like my old one! It's on a completely different subject but it has pretty much the same page

layout and design. Outstanding choice of colors!

Also visit my blog post - free the vbucks

My brother recommended I might like this web site. He was totally right.

This post truly made my day. You can not imagine simply how much time I had spent for this info!


Laconian (Julius)

Its like you learn my mind! You seem to understand so

much about this, such as you wrote the e book in it or something.

I feel that you just could do with some % to force the message house a

bit, however instead of that, that is wonderful blog.

A great read. I will certainly be back.

Here is my blog: free vbucks trusted pharmacy canada
canadian pharmacycanadian pharmacy
most reliable canadian pharmacies

always i used to read smaller content that also clear

their motive, and that is also happening with this paragraph which I am reading at this time.

Visit my blog post :: free vbucks generator online pharmacies mexico
pharmacy canada online prescriptions
drugs for sale canadian pharmacies without an rx
canadian medications pharmacy
drugstore online shopping


Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
1 + 3 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.