На страницах этого блога уже было описано применение технологии 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. Тогда кеш затрется. 

Рассказать друзьям
author.jpg

Платная консультация по вопросам 2500 руб/час

Прочитали статью и остались вопросы? Меня зовут Валерий и я её автор. С радостью объясню Вам в скайпе все затруднительные моменты, которые остались за рамками статьи!

Подробнее ...

Добавить комментарий


Комментарии   

Sfera1
+1 # Sfera1 03.03.2015 00:07
Чудно написано, но только вообще ничего не понятно.
По этому и не нужно.
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
bookep.info
0 # bookep.info 28.12.2020 02:16
Very good article. I'm going through some of these issues as
well..

my web page ... bookep.info
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
slotpulsa388.xyz
0 # slotpulsa388.xyz 28.12.2020 02:45
I think this is one of the most significant info for me. And i am glad reading your article.
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
judipulsa77.xyz
0 # judipulsa77.xyz 28.12.2020 03:43
Heya i am for the first time here. I found this board and I find It really
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
poker idn pulsa
0 # poker idn pulsa 28.12.2020 04:59
Definitely believe that which you stated. Your favorite
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
daftar s128
0 # daftar s128 28.12.2020 05:09
Excellent, what a webpage it is! This website provides valuable facts to us, keep it up.


Also visit my web-site ... daftar s128
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
joker123
0 # joker123 28.12.2020 05:21
I got this web site from my buddy who informed me concerning this web page and at the moment this time I am browsing this web site and reading
very informative articles or reviews at this place.

Review my web site - joker123
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
sabung ayam sv388
0 # sabung ayam sv388 28.12.2020 05:25
I was recommended this web site by my cousin. I am not sure whether this post is written by him as nobody else know such detailed about my difficulty.
You are incredible! Thanks!

Feel free to visit my blog post; sabung ayam
sv388
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
taruhanprediksi.net
0 # taruhanprediksi.net 28.12.2020 06:16
Unquestionably believe that which you stated. Your favorite justification appeared to be on the web the simplest thing to be aware of.
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
forum judi online
0 # forum judi online 28.12.2020 07:30
If you are going for most excellent contents like I do,
just pay a visit this web site everyday as it offers feature contents,
thanks

my web page :: forum judi online
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
pokerpulsa77.xyz
0 # pokerpulsa77.xyz 28.12.2020 07:52
Your style is really unique in comparison to other folks
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
poker online
0 # poker online 28.12.2020 08:34
Good site you have here.. It's difficult to find quality writing like yours nowadays.
I really appreciate individuals like you! Take care!!



Here is my webpage poker
online
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
download s128
0 # download s128 28.12.2020 08:52
Hello there! This is my 1st comment here so I
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
sekiki.com
0 # sekiki.com 28.12.2020 10:03
Its like you read my mind! You seem to know so much about this, like you wrote
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
poker online
0 # poker online 28.12.2020 11:58
Wow that was unusual. I just wrote an extremely long comment but
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
sabung ayam s128
0 # sabung ayam s128 28.12.2020 13:06
whoah this blog is excellent i really like studying your articles.

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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
www.betayam.net
0 # www.betayam.net 28.12.2020 17:28
I loved as much as you will receive carried out right
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
joker slot online
0 # joker slot online 28.12.2020 18:18
I would like to thank you for the efforts you've put in penning this
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
sabung ayam
0 # sabung ayam 28.12.2020 19:06
We're a group of volunteers and starting a new scheme in our community.
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
slotpulsa303.xyz
0 # slotpulsa303.xyz 28.12.2020 21:06
Hey I know this is off topic but I was wondering if you knew
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
poker online terbaik
0 # poker online terbaik 28.12.2020 22:46
My spouse and I stumbled over here from a different website and thought I may as well
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
login slot online
0 # login slot online 29.12.2020 00:57
Hello there! This is my first visit to your blog!
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
daftar poker pulsa
0 # daftar poker pulsa 29.12.2020 01:37
I know this if off topic but I'm looking into starting my own weblog and was curious
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
biyaagaw.com
0 # biyaagaw.com 29.12.2020 04:03
I've been surfing online more than 3 hours today, yet I never found any interesting article like yours.
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
casino deposit pulsa
0 # casino deposit pulsa 29.12.2020 05:20
If you would like to increase your knowledge simply keep visiting this web page and be updated with the newest news update posted here.


Feel free to surf to my site: casino deposit pulsa
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
judi deposit pulsa
0 # judi deposit pulsa 29.12.2020 07:11
Today, I went to the beach front with my children. I found a sea shell and gave it to my 4 year old daughter and said "You can hear the ocean if you put this to your ear."
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
pokerr-88.com
0 # pokerr-88.com 29.12.2020 10:08
Heya i am for the primary time here. I came across this board and I find
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
poker pulsa
0 # poker pulsa 29.12.2020 10:51
Hey would you mind sharing which blog platform you're working with?
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
s128 sabung ayam
0 # s128 sabung ayam 29.12.2020 13:23
This is my first time visit at here and i am truly impressed
to read all at one place.

Take a look at my web-site s128 sabung ayam
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
daftar s128
0 # daftar s128 29.12.2020 14:20
Hi there to every , since I am in fact eager of reading this webpage's post to be updated daily.
It contains good information.

Here is my web blog daftar
s128
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
s128
0 # s128 29.12.2020 14:25
Have you ever thought about publishing an e-book or
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
www.livebanteng.net
0 # www.livebanteng.net 29.12.2020 15:21
It's awesome in support of me to have a web page, which is beneficial for my experience.
thanks admin

My site www.livebanteng.net
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
adubantengonline.com
0 # adubantengonline.com 30.12.2020 11:34
I loved as much as you'll receive carried out right here.
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
ayamlive.org
0 # ayamlive.org 30.12.2020 11:43
I think this is among the most significant information for me.
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
slot pulsa
0 # slot pulsa 30.12.2020 11:55
Please let me know if you're looking for a article writer for
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
pokerpulsa303.xyz
0 # pokerpulsa303.xyz 30.12.2020 18:25
I will immediately clutch your rss feed as I can not to find your e-mail subscription hyperlink or newsletter service.
Do you've any? Please allow me recognize in order that I may just subscribe.

Thanks.

my site - pokerpulsa303.xyz
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
sabung ayam s128
0 # sabung ayam s128 31.12.2020 03:52
Thanks for your personal marvelous posting! I certainly enjoyed reading it, you will be a
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
agen judi online
0 # agen judi online 31.12.2020 04:34
I'll right away seize your rss feed as I can't in finding your email subscription hyperlink or e-newsletter
service. Do you have any? Kindly allow me recognize
so that I could subscribe. Thanks.

My site: agen judi online
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
slotpulsa365.xyz
0 # slotpulsa365.xyz 31.12.2020 06:02
Heya i am for the first time here. I came across this board and I in finding
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
login slot online
0 # login slot online 31.12.2020 08:08
These are actually great ideas in on the topic of blogging.
You have touched some fastidious points here. Any way keep up wrinting.



My blog login slot
online
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
agensabung.org
0 # agensabung.org 31.12.2020 08:46
It's a shame you don't have a donate button! I'd
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
ayamindo.com
0 # ayamindo.com 31.12.2020 13:21
I visited various sites but the audio quality for audio songs current at this web site is in fact wonderful.


my web blog ayamindo.com
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
http://pokeronl.net
0 # http://pokeronl.net 31.12.2020 14:54
Very nice article, exactly what I wanted to find.


Here is my web blog; http://pokeronl.net
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
login poker pulsa
0 # login poker pulsa 31.12.2020 17:12
Right here is the perfect web site for anybody who hopes to understand this topic.
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
daftar s128
0 # daftar s128 31.12.2020 18:30
Hello this is kinda of off topic but I was wondering
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
poker idn pulsa
0 # poker idn pulsa 31.12.2020 20:33
I every time used to study article in news papers but now as I am a user of internet thus from now I am using net for
articles, thanks to web.

Also visit my page; poker idn pulsa
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
sportsidn.com
0 # sportsidn.com 31.12.2020 22:07
Wonderful post however , I was wondering if you could write
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
kungfuchicken.me
0 # kungfuchicken.me 01.01.2021 00:23
Hi there exceptional website! Does running a blog like this take a great deal
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
judipulsa303.xyz
0 # judipulsa303.xyz 01.01.2021 10:21
WOW just what I was looking for. Came here by searching for кеширование Joomla

my web blog: judipulsa303.xyz
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
poker online
0 # poker online 01.01.2021 14:45
Your style is very unique compared to other
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
deposit pulsa
0 # deposit pulsa 01.01.2021 20:50
Good post. I'm dealing with a few of these issues as well..



Also visit my site - deposit pulsa
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
judiayam.us
0 # judiayam.us 01.01.2021 22:07
This is very interesting, You're a very skilled blogger.
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору
login slot online
0 # login slot online 02.01.2021 07:42
I'm gone to say to my little brother, that he should also pay a
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
Ответить | Ответить с цитатой | Цитировать | Сообщить модератору