На страницах этого блога уже было описано применение технологии memcache для кеширования веб страниц целиком. действительно, это очень удобная технология позволяет делать это очень быстро и надежно, при этом нет необходимости держать огромную папку закешированного содержимого. Все лежит в оперативной памяти.
Конечно, если памяти доступной для этого расширения не достаточно, то тут ничего не сделаешь. Но для выделенных сервером, как было в моем случае, это не проблема.
В этой статье я расскажу, как закешировать sql запросы к базе данных.
В любой нормальной системе, будь то CMS или фреймворк, есть срипт, который отвечает за запросы к базе данных. Мало кто из программистов в наше время пишет
mysql_query('select * from tablename')
всегда есть некая прослойка. Если ее нет, то ее не сложно написать. В этой статье я буду ускорять CMS Joomla и при этом буду использовать свою прослойку uno, которая в свою очередь является прослойкой над Joomla прослойкой над PDO интерфейсом. Вот такие хитросплетения.
В uno есть несколько методов для выборки данных: getRows,getRows,count, getRowsBySQL,exists,getRowsBySQL
Вот их и нужно кешировать. Для этого в каждый метод, необходимо добавить параметр: $usecache = false. Далее, напишу, как это работает на примере только getRow. Предполагается, что у вас уже есть класс для работы с memcahe
static public function getRow($table,$conditions=false,$colums=array('*'),$order = false,$offset = 0, $usecache = false){ $key = md5(serialize(array($table,$conditions,$colums,$order,$offset))); if( $usecache and $result = mem::gi()->get($key)) return $result; $result = self::query($table,$conditions,$colums,$order,1,$offset)->loadAssoc(); if( $usecache!==false ){ mem::gi()->set($key,$result,$usecache); } return $result; }
При использовании метода, в параметр $usecache, нужно подать количество секунд для хранения данных в memcache, по истечении которых, кеш нужно будет обновить.
В статичных сайтах, этим значением может быть очень больше число. Если сайт создан исключительно для продажи контекстной рекламы Google (Гугл), и представляет собой множество интересных постов, то там можно кешировать и при помощи файлов.
Но для динамичных порталов, в которых такое кеширование и имеет смысл делать, нужно предусмотреть обновление кеша.
К примеру, пользователь зарегистрировался. После этого, список ранее закешированных пользователей нужно обновить. Для этого в $usememcache нужно подать 0. Тогда кеш затрется.
Комментарии
По этому и не нужно.
well..
my web page ... bookep.info
But wanna remark on some general things, The website style is
perfect, the articles is really nice : D. Good job, cheers
Feel free to surf to my blog post: slotpulsa388.xyz
useful & it helped me out much. I hope to give something back and aid others like you helped me.
Stop by my web blog; judipulsa77.xyz
justification appeared to be on the web the easiest thing to be aware of.
I say to you, I definitely get annoyed while people think about worries that they plainly do not know
about. You managed to hit the nail upon the top and defined out the whole thing
without having side effect , people can take a signal.
Will probably be back to get more. Thanks
Also visit my site poker idn pulsa
Also visit my web-site ... daftar s128
very informative articles or reviews at this place.
Review my web site - joker123
You are incredible! Thanks!
Feel free to visit my blog post; sabung ayam
sv388
I say to you, I definitely get annoyed while people consider worries that they plainly don't
know about. You managed to hit the nail upon the top as well as
defined out the whole thing without having side-effects , people could take
a signal. Will probably be back to get more. Thanks
Review my homepage taruhanprediksi.net
just pay a visit this web site everyday as it offers feature contents,
thanks
my web page :: forum judi online
I've read stuff from. Thanks for posting when you have the opportunity, Guess I'll just bookmark this
web site.
my web site - pokerpulsa77.xyz
I really appreciate individuals like you! Take care!!
Here is my webpage poker
online
just wanted to give a quick shout out and say I really enjoy reading your posts.
Can you suggest any other blogs/websites/forums
that cover the same subjects? Thanks a lot!
Here is my web site - download s128
the book in it or something. I think that you can do with some pics to drive the message home a
bit, but other than that, this is magnificent blog. A great
read. I will certainly be back.
My website sekiki.com
after I clicked submit my comment didn't show up. Grrrr...
well I'm not writing all that over again. Regardless, just wanted to say superb blog!
My homepage poker online
Stay up the great work! You realize, many persons are hunting round
for this information, you can aid them greatly.
Feel free to surf to my page sabung ayam
s128
here. The sketch is tasteful, your authored material stylish.
nonetheless, you command get got an impatience over that you wish be
delivering the following. unwell unquestionably come more formerly again since exactly the same nearly a lot often inside case you shield this increase.
my webpage; www.betayam.net
site. I am hoping to view the same high-grade
content by you in the future as well. In fact, your creative writing abilities has
encouraged me to get my own site now ;)
Here is my webpage; joker slot online
Your website provided us with valuable information to work on. You've done an impressive job and our whole community will be thankful to you.
Also visit my blog post: sabung ayam
of any widgets I could add to my blog that automatically tweet my newest twitter updates.
I've been looking for a plug-in like this for quite some time
and was hoping maybe you would have some experience with something like this.
Please let me know if you run into anything.
I truly enjoy reading your blog and I look forward to
your new updates.
Also visit my web page :: slotpulsa303.xyz
check things out. I like what I see so i am just following you.
Look forward to looking into your web page repeatedly.
Take a look at my blog post :: poker online terbaik
We are a group of volunteers and starting a new project in a community in the same niche.
Your blog provided us useful information to work on. You
have done a wonderful job!
Here is my webpage; login slot online
what all is needed to get setup? I'm assuming having a blog
like yours would cost a pretty penny? I'm not very internet
smart so I'm not 100% sure. Any recommendations or advice would be greatly
appreciated. Kudos
Also visit my website; daftar poker pulsa
It's pretty worth enough for me. In my view, if all web owners
and bloggers made good content as you did, the net will be
much more useful than ever before.
Feel free to visit my blog :: biyaagaw.com
Feel free to surf to my site: casino deposit pulsa
She placed the shell to her ear and screamed. There was a hermit crab inside and it pinched her ear.
She never wants to go back! LoL I know this is completely off topic but
I had to tell someone!
My blog: judi deposit pulsa
It truly useful & it helped me out much. I hope to present one thing again and help others such as you aided me.
Here is my web blog ... pokerr-88.com
I'm going to start my own blog soon but I'm having a hard time deciding between BlogEngine/Wordpress/B2evolution and Drupal.
The reason I ask is because your design and style seems different then most blogs
and I'm looking for something unique. P.S Apologies for getting
off-topic but I had to ask!
Feel free to surf to my web page ... poker pulsa
to read all at one place.
Take a look at my web-site s128 sabung ayam
It contains good information.
Here is my web blog daftar
s128
guest authoring on other sites? I have a blog based upon on the same subjects you discuss and
would love to have you share some stories/information. I know my readers
would appreciate your work. If you're even remotely interested, feel
free to shoot me an e-mail.
Feel free to surf to my web blog - s128
thanks admin
My site www.livebanteng.net
The sketch is tasteful, your authored subject matter stylish.
nonetheless, you command get bought an shakiness over that
you wish be delivering the following. unwell unquestionably come further
formerly again since exactly the same nearly a lot often inside case you shield this increase.
my webpage :: adubantengonline.com
And i'm glad reading your article. But want to remark on some general
things, The site style is ideal, the articles is really excellent : D.
Good job, cheers
Feel free to surf to my site: ayamlive.org
your site. You have some really good posts and I
believe I would be a good asset. If you ever want to take
some of the load off, I'd absolutely love to write some material
for your blog in exchange for a link back to mine.
Please shoot me an email if interested. Many thanks!
Here is my homepage - slot pulsa
Do you've any? Please allow me recognize in order that I may just subscribe.
Thanks.
my site - pokerpulsa303.xyz
great author.I will remember to bookmark your blog and will come back at some point.
I want to encourage continue your great posts, have a nice morning!
Feel free to visit my web blog ... sabung ayam s128
service. Do you have any? Kindly allow me recognize
so that I could subscribe. Thanks.
My site: agen judi online
It truly helpful & it helped me out a lot.
I hope to provide one thing back and aid others such as you
aided me.
Here is my blog post - slotpulsa365.xyz
You have touched some fastidious points here. Any way keep up wrinting.
My blog login slot
online
certainly donate to this excellent blog! I guess for
now i'll settle for book-marking and adding your RSS feed
to my Google account. I look forward to new updates and will talk
about this blog with my Facebook group. Talk soon!
Also visit my web site - agensabung.org
my web blog ayamindo.com
Here is my web blog; http://pokeronl.net
You know a whole lot its almost hard to argue
with you (not that I really would want to…HaHa). You certainly put
a brand new spin on a topic that has been written about for years.
Great stuff, just wonderful!
Also visit my web page - login poker pulsa
if blogs use WYSIWYG editors or if you have to manually code with HTML.
I'm starting a blog soon but have no coding knowledge so I wanted to get guidance from someone with experience.
Any help would be enormously appreciated!
my blog ... daftar s128
articles, thanks to web.
Also visit my page; poker idn pulsa
a litte more on this subject? I'd be very thankful if you could elaborate a little bit more.
Bless you!
Feel free to visit my blog post: sportsidn.com
of work? I've virtually no knowledge of computer programming however I had been hoping to start my own blog soon. Anyhow, if you have any recommendations or techniques for new blog owners please share.
I know this is off topic but I simply needed to ask. Thanks!
My blog; kungfuchicken.me
my web blog: judipulsa303.xyz
folks I've read stuff from. Thank you for posting when you
have the opportunity, Guess I will just bookmark this page.
Review my blog: poker
online
Also visit my site - deposit pulsa
I have joined your feed and look forward to seeking more
of your wonderful post. Also, I have shared your website in my social
networks!
Also visit my website :: judiayam.us
quick visit this web site on regular basis to obtain updated from latest gossip.
Feel free to surf to my web blog; login slot online
RSS лента комментариев этой записи