Development Articles
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherDevelopment Articles

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 6th, 2003, 10:37 AM
Ducani
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Caching With PHP Cache_Lite

Caching With PHP Cache_Lite

June 06, 2003 - As Web applications become more and more complex, clever developers can use application-level caching to improve the performance of their PHP scripts. This article shows you how, discussing the PEAR Cache_Lite class with examples that illustrate how it can be used in a live environment.

Please discuss this article in this thread. You can read the article here .

Reply With Quote
  #2  
Old June 7th, 2003, 03:39 AM
nz-dev nz-dev is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 5 nz-dev User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cache and array

Hi guys,

Excellent article.
Few questions:
how cache_lite works with array? I tested with string, works perfect.

This is a code from example except data is changed from string to array.

<?
...

if($data = $Cache_Lite->get('123')) {
echo('Cache Hit !<br>');
foreach($data as $k) echo $k;
}
else {
echo('Cache Missed !<br>');
$data = array();
for($i=0;$i<10;$i++) { $data[] = $i; }
foreach($data as $j) echo $j;
$Cache_Lite->save($data);
}
...
?>

all the time 'Cache Missed' message. Any ideas?
Thanks a lot.

Reply With Quote
  #3  
Old June 7th, 2003, 05:52 PM
nz-dev nz-dev is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 5 nz-dev User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
is it thread in diff forum?

subj.

Last edited by nz-dev : June 7th, 2003 at 05:55 PM.

Reply With Quote
  #4  
Old June 9th, 2003, 05:06 AM
gmilbourn gmilbourn is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Surrey UK
Posts: 2 gmilbourn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks but . . .

Thanks for the info. Nice article.

One of my concerns about PHP is scaleability.
I guess there ocassions when you can foresee bottle necks that make it worth using caching but a more practical situation is where you need to use it to improve perfromance of existing applications.

So my question is about how you decide where to use caching.
Are there tools for dermining bottle necks in performance? Or maybe manual techniques?

Perhaps another article from mr melonfire?

Cheers

Reply With Quote
  #5  
Old June 9th, 2003, 05:58 AM
melonfire melonfire is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Posts: 45 melonfire User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
try the apachebench utility from apache.org to see whcih parts of your site are slow and might beenfit from caching

Reply With Quote
  #6  
Old June 9th, 2003, 08:54 AM
GiLuX GiLuX is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2000
Location: amsterdam
Posts: 62 GiLuX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
forgive me, but i never played around with pear untill now,
does this work when having set a basedir restriction?

and because this function is whinin pear,
i figured you should do: require_once "PEAR.php";
at least, that is what it says in the pear documentation.
but this also gives me:
File(/usr/local/lib/php/PEAR.php) is not within the allowed path(s):
the pear docu doesnt mention anything about basedir restrictions.

i'm running php 4.3.1 so pear should be installed.

any ideas?

btw,
nice article
__________________
you can get anything you want at alices restaurant

Reply With Quote
  #7  
Old June 9th, 2003, 08:53 PM
nz-dev nz-dev is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 5 nz-dev User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
to gmilbourn

Useful for web services or databases. Rather then connect to "web service" server/db with high traffic (about 5000-7000 visitors per day) every minute, it is enough to cachce all dynamic pages for 3 hours and after check web service/db if data is changed.

Reply With Quote
  #8  
Old June 10th, 2003, 06:12 AM
melonfire melonfire is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Posts: 45 melonfire User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Quote:
Originally posted by GiLuX
forgive me, but i never played around with pear untill now,
does this work when having set a basedir restriction?

and because this function is whinin pear,
i figured you should do: require_once "PEAR.php";
at least, that is what it says in the pear documentation.
but this also gives me:
File(/usr/local/lib/php/PEAR.php) is not within the allowed path(s):
the pear docu doesnt mention anything about basedir restrictions.

i'm running php 4.3.1 so pear should be installed.

any ideas?

btw,
nice article


Not sure about using basedir with PEAR, does it work if you remove the basedir restriction?
__________________
--
Articles, tutorials and more, all at http://www.melonfire.com/community/columns/trog/

Reply With Quote
  #9  
Old June 23rd, 2003, 02:58 AM
waro waro is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 7 waro User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 16 sec
Reputation Power: 0
Can we use it stand-alone. I mean all I have to do is upload the cache lite package and use it without another PEAR package. I ask this cause not all ISP give PEAR.

thx

Reply With Quote
  #10  
Old June 23rd, 2003, 07:59 AM
melonfire melonfire is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Posts: 45 melonfire User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
yes you can. however most PEAR packages require you to also ensure that the primary PEAR class be installed for error handling etc. you can install that one also manually, just remember to modify all the incldue() paths to point to the correct locations

Reply With Quote
  #11  
Old December 14th, 2003, 01:48 PM
joeymanley joeymanley is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 14 joeymanley User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
It works, but with an error message

When running the first example, I get this error:

Warning: Invalid argument supplied for foreach() in /home/virtual/site3/fst/usr/share/pear/Lite.php on line 228

That said, the caching does actually work. Reloading gives me the cached version. Setting error_reporting to zero hides the error just fine, and it does seem to work -- but any idea why this is happening?

This also happens when I run the similar code from the similar tutorial distributed with the Lite.php class.

I'm running PHP on an Ensim 3.5 Pro box, which may have something to do with it (I'm both the site administrator and the Appliance Administrator for this site & this Ensim installation).


Joey
www.moderntales.com

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherDevelopment Articles > Caching With PHP Cache_Lite


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT