RE: new snapshot - new fetch functionality and caching
| From: | IpSo | Date: | Thu, 14 Mar 2002 05:39:23 +0000 |
| Subject: | RE: new snapshot - new fetch functionality and caching | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-3049@lists.php.net to get a copy of this message | ||
Speaking of caching, would anyone be interested in a couple generic
caching functions I wrote? Its all quite simple, two functions, one for
writing to the cache, another for reading the cache, and it works for
pretty much any type of data.
I use it for almost everything in the project I'm currently working on.
From caching certain SQL query results, to caching things like user id's
to user name mappings.
You can set the expire time on a per cache entry basis, so for instance
if you want to cache an SQL query result for an hour, and another query
right after it for a minute, its all very easy. As well it of course
only reads from the cache file once per "page view" and stores the data
in memory for quick access later on in the script.
I prefer this method of caching to database layers that cache just SQL
queries, or template engines that cache entire pages. It gives you much
more fine grained control over the cached data.
I would have to clean it up quite a bit before I released it, but I'm
just curious if people think this would be useful.
On Wed, 2002-03-13 at 19:23, Jimmy Harlindong wrote:
> Oh yes that would be much cleaner, I agree.
>
> OK here's another idea.... can the fetch be cached, and say either
> refresh the fetch only when there's new document (using http expire or
> date?) or only refetch at a certain time and at other time use the
> cache? It'd be useful if I want to fetch a news site say every 3 hours
> or every 9 am in the morning (barring any time difference)
>
> I think I can write the extraction routine as a custom function or
> better yet if the *extracted* data can be cached as well.... oh well
> ideas ideas :)
>
> cheers
>
> > -----Original Message-----
> > From: Monte Ohrt [mailto:monte@ispi.net]
> > Sent: Thursday, 14 March 2002 1:03 PM
> > To: Jimmy Harlindong
> > Cc: smarty@lists.ispi.net
> > Subject: Re: [smarty] RE: new snapshot - new fetch functionality
> >
> >
> > like what? strip out the links, or strip out the html tags?
> >
> > Maybe that should be another function or modifier, so you can
> > use it for
> > any text.
> >
> > {fetch file=$url assign="contents"}
> >
> > {$contents|extract_links}
> > {$contents|strip_html_tags}
> >
> > Jimmy Harlindong wrote:
> > >
> > > Monte,
> > >
> > > This is great, and maybe you can also add the function to
> > let us filter
> > > / extract certain parts of the fetched document too?
> > >
> > > Cheers
> > > Jimmy
>
>
> ---
> You are currently subscribed to smarty as: ipso@snappymail.ca
> To unsubscribe send a blank email to $subst('Email.Unsub')
> Visit Smarty's homepage at
> http://www.phpinsider.com/php/code/Smarty/