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:
mysql> desc cache; +------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------+--------------+------+-----+---------+-------+ | cid | varchar(255) | NO | PRI | | | | data | longblob | YES | | NULL | | | expire | int(11) | NO | MUL | 0 | | | created | int(11) | NO | | 0 | | | serialized | smallint(6) | NO | | 0 | | +------------+--------------+------+-----+---------+-------+
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:
• $cid: A unique cache ID string that acts as a key to the data. Colons are used to delimit the hierarchy of possibilities. • $bin: The name of the cache bin to store the data in. Valid core values are 'cache_block', 'cache_bootstrap', 'cache_field', 'cache_filter', 'cache_form', 'cache_menu', 'cache_page', 'cache_update', or 'cache' for the default cache. • $data: The data to store in the cache. PHP objects and arrays will be automatically serialized. • $expire: The length of time for which the cached data is valid. Possible values are CACHE_PERMANENT, CACHE_TEMPORARY, or a Unix timestamp. If a Unix timestamp is given, the data will be treated as if it were marked CACHE_TEMPORARY after the current time exceeds the Unix timestamp.
A common iteration pattern for cache_set() can be seen in modules/filter/filter.module:
// Store in cache with a minimum expiration time of 1 day. if ($cache) { cache_set($cid, $text, 'cache_filter', REQUEST_TIME + (60 * 60 * 24)); }
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:
• $cid: This is the cache ID of the data to retrieve. • $bin: This is the name of the cache bin to store the data in. Valid core values are 'cache_block', 'cache_bootstrap', 'cache_field', 'cache_filter', 'cache_form', '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.
// Check for a cached version of this piece of text. if ($cached = cache_get($cid, 'cache_filter')) { return $cached->data; }
Comments
Rickyapalk (not verified)
Tue, 2019-12-03 14:47
Permalink
lowest price generic viagra 100mg
Visit my webpage - https://www.myonlinebuy.us/best-erectile-dysfunction-pills
Ona (not verified)
Tue, 2020-08-25 00:37
Permalink
Add new comment | Moi Verhole
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
Angel (not verified)
Thu, 2020-09-17 07:10
Permalink
Add new comment | Moi Verhole
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.
Grant
Review my page - Grant
AlfredoLow (not verified)
Thu, 2020-01-30 16:24
Permalink
canadian pharmacy king
http://tribtaiti.webcindario.com/ canadian pharmacy meds
best canadian mail order pharmacies http://tribtaiti.webcindario.com/
canadian pharcharmy online24 http://tribtaiti.webcindario.com/
AlfredoLow (not verified)
Sun, 2020-02-02 22:44
Permalink
canadianpharmacyusa24h is it legal
https://viagrawwithoutdoctor.com/ canadian pharmacy meds
canadian pharmacys https://viagrawwithoutdoctor.com/
northwest pharmacies online https://viagrawwithoutdoctor.com/
AlfredoLow (not verified)
Sun, 2020-02-02 23:54
Permalink
north west pharmacy canada
https://viagrawwithoutdoctor.com/ prescription drugs without prior prescription
canadian pharmaceuticals for usa sales https://viagrawwithoutdoctor.com/
most reliable canadian online pharmacies https://viagrawwithoutdoctor.com/
AlfredoLow (not verified)
Mon, 2020-02-03 01:02
Permalink
canadian pharmacy viagra
https://viagracwithoutdoctor.com/ canadian pharmacy online 24
canadian pharcharmy online https://viagracwithoutdoctor.com/
global pharmacy canada https://viagracwithoutdoctor.com/
Bettina (not verified)
Wed, 2020-08-12 04:30
Permalink
Add new comment | Moi Verhole
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.
Ricardo (not verified)
Tue, 2020-08-25 02:28
Permalink
Add new comment | Moi Verhole
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.
Cheers!
Also visit my homepage - free vbucks generator
Regina (not verified)
Tue, 2020-08-25 03:38
Permalink
Add new comment | Moi Verhole
I visited various web pages however the audio feature for audio songs
existing at this site is actually superb.
My homepage ... free the vbucks
Pansy (not verified)
Tue, 2020-08-25 00:39
Permalink
Add new comment | Moi Verhole
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
Valerie (not verified)
Tue, 2020-08-25 02:32
Permalink
Add new comment | Moi Verhole
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
AlfredoLow (not verified)
Mon, 2020-02-03 02:08
Permalink
canadian rx
https://canadianlpharmacy.com/ canada medications buy
canadian online pharmacies https://canadianlpharmacy.com/
the best canadian online pharmacies https://canadianlpharmacy.com/
AlfredoLow (not verified)
Mon, 2020-02-03 04:16
Permalink
candida viagra
https://viagrawwithoutdoctor.com/ northwest pharmacies online
pharmacy canada reviews https://viagrawwithoutdoctor.com/
canadian government approved pharmacies https://viagrawwithoutdoctor.com/
AlfredoLow (not verified)
Mon, 2020-02-03 05:26
Permalink
canada pharmacies
https://canadianlpharmacy.com/ canadian pharmacy no prescription
online canadian discount pharmacies https://canadianlpharmacy.com/
online pharmacy https://canadianlpharmacy.com/
Britt (not verified)
Tue, 2020-08-25 02:29
Permalink
Add new comment | Moi Verhole
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
blogengine.net. 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
AlfredoLow (not verified)
Mon, 2020-02-03 06:32
Permalink
is trust pharmacy in canada legitimate
https://canadianhpharmacy.com/ pharmacy canada best
canada viagra https://canadianhpharmacy.com/
canada online pharmacies medication https://canadianhpharmacy.com/
Victoria (not verified)
Tue, 2020-08-25 02:14
Permalink
Add new comment | Moi Verhole
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
Luther (not verified)
Tue, 2020-08-25 06:37
Permalink
Add new comment | Moi Verhole
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
AlfredoLow (not verified)
Mon, 2020-02-03 07:36
Permalink
canadian pharmacy world
https://canadianlpharmacy.com/ pharmacy times
canadian pharmaceuticals online https://canadianlpharmacy.com/
online drug store https://canadianlpharmacy.com/
AlfredoLow (not verified)
Mon, 2020-02-03 08:39
Permalink
north west pharmacies canada
https://canadianlpharmacy.com/ canada online pharmacies medication
canadian online pharmacies https://canadianlpharmacy.com/
pharmacy https://canadianlpharmacy.com/
AlfredoLow (not verified)
Mon, 2020-02-03 09:44
Permalink
online pharmacies tech school
https://viagrawwithoutdoctor.com/ canadian prescriptions online serc 24 mg
canadian discount pharmacies in canada https://viagrawwithoutdoctor.com/
pharmacy times https://viagrawwithoutdoctor.com/
Chanda (not verified)
Tue, 2020-08-25 06:27
Permalink
Add new comment | Moi Verhole
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
AlfredoLow (not verified)
Mon, 2020-02-03 10:55
Permalink
the best canadian online pharmacies
https://canadianhpharmacy.com/ canadian rxlist
buy viagra usa https://canadianhpharmacy.com/
buy viagrow https://canadianhpharmacy.com/
Jasmin (not verified)
Tue, 2020-08-25 00:18
Permalink
Add new comment | Moi Verhole
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
Ermelinda (not verified)
Tue, 2020-08-25 00:56
Permalink
Add new comment | Moi Verhole
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
Hassan (not verified)
Tue, 2020-08-25 01:57
Permalink
Add new comment | Moi Verhole
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
AlfredoLow (not verified)
Mon, 2020-02-03 12:02
Permalink
canadian pharmacies-24h
https://canadianhpharmacy.com/ canadian drug
drugstore online shopping https://canadianhpharmacy.com/
canadian cialis https://canadianhpharmacy.com/
Nadine (not verified)
Mon, 2020-08-24 23:34
Permalink
Add new comment | Moi Verhole
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
Blanche (not verified)
Tue, 2020-08-25 02:52
Permalink
Add new comment | Moi Verhole
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
Collette (not verified)
Tue, 2020-08-25 04:16
Permalink
Add new comment | Moi Verhole
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
Ryder (not verified)
Tue, 2020-08-25 05:18
Permalink
Add new comment | Moi Verhole
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
Silas (not verified)
Tue, 2020-08-25 05:52
Permalink
Add new comment | Moi Verhole
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
AlfredoLow (not verified)
Mon, 2020-02-03 14:03
Permalink
rx from canada
https://viagracwithoutdoctor.com/ online canadian discount pharmacies
trust pharmacy canada reviews https://viagracwithoutdoctor.com/
canadian pharmacy cialis https://viagracwithoutdoctor.com/
Breanna (not verified)
Tue, 2020-08-25 00:48
Permalink
Add new comment | Moi Verhole
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
Winifred (not verified)
Tue, 2020-08-25 05:16
Permalink
Add new comment | Moi Verhole
It's an remarkable paragraph in support of all the internet visitors; they will obtain benefit from it I am
sure.
Here is my web site free vbucks
AlfredoLow (not verified)
Mon, 2020-02-03 14:51
Permalink
pharmacy times
https://canadianhpharmacy.com/ north west pharmacies canada
canadian drug store https://canadianhpharmacy.com/
north west pharmacies canada https://canadianhpharmacy.com/
Carrol (not verified)
Tue, 2020-08-25 01:22
Permalink
Add new comment | Moi Verhole
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
AlfredoLow (not verified)
Mon, 2020-02-03 15:41
Permalink
canadian pharmacies
https://viagrawwithoutdoctor.com/ canada medication
canada pharmacies online prescriptions https://viagrawwithoutdoctor.com/
are canadian online pharmacies safe https://viagrawwithoutdoctor.com/
Candelaria (not verified)
Tue, 2020-08-25 02:43
Permalink
Add new comment | Moi Verhole
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
AlfredoLow (not verified)
Mon, 2020-02-03 16:11
Permalink
drugs for sale usa
https://viagracwithoutdoctor.com/ canadian pharmacy no prescription
canada viagra https://viagracwithoutdoctor.com/
pharmacy onesource https://viagracwithoutdoctor.com/
AlfredoLow (not verified)
Mon, 2020-02-03 16:47
Permalink
canadian pharmaceuticals nafta
https://canadianlpharmacy.com/ drugstore online india
buy vistagra usa https://canadianlpharmacy.com/
drugstore online reviews https://canadianlpharmacy.com/
Gerald (not verified)
Wed, 2020-03-11 13:40
Permalink
Add new comment | Moi Verhole
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!
Thanks!
Laconian (Julius)
AlfredoLow (not verified)
Mon, 2020-02-03 17:28
Permalink
prescription drugs without prior prescription
https://viagracwithoutdoctor.com/ aarp recommended canadian online pharmacies
drugs for sale deep web https://viagracwithoutdoctor.com/
canadian pharmacys https://viagracwithoutdoctor.com/
Chelsea (not verified)
Tue, 2020-08-25 02:40
Permalink
Add new comment | Moi Verhole
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
AlfredoLow (not verified)
Mon, 2020-02-03 18:10
Permalink
canada pharmacies online prescriptions
https://canadianhpharmacy.com/ trusted pharmacy canada
canadian pharmacycanadian pharmacy https://canadianhpharmacy.com/
most reliable canadian pharmacies https://canadianhpharmacy.com/
Concetta (not verified)
Tue, 2020-08-25 03:23
Permalink
Add new comment | Moi Verhole
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
AlfredoLow (not verified)
Mon, 2020-02-03 18:55
Permalink
pharmacy onesource
https://viagracwithoutdoctor.com/ online pharmacies mexico
pharmacy canada online prescriptions https://viagracwithoutdoctor.com/
drugs for sale https://viagracwithoutdoctor.com/
AlfredoLow (not verified)
Mon, 2020-02-03 19:41
Permalink
discount canadian pharmacies
https://viagrawwithoutdoctor.com/ north west pharmacy canada
pharmacy near me https://viagrawwithoutdoctor.com/
canadian medications 247 https://viagrawwithoutdoctor.com/
AlfredoLow (not verified)
Mon, 2020-02-03 20:31
Permalink
canadian online pharmacies legal
https://canadianlpharmacy.com/ canadian pharmacies without an rx
canadian medications pharmacy https://canadianlpharmacy.com/
drugstore online shopping https://canadianlpharmacy.com/
Pages
Add new comment