Results 1 to 6 of 6

Thread: Nen Cache - File cache class

  1. #1
    Senior Member morency's Avatar
    Join Date
    Oct 2008
    Location
    23.8134710 , 44.3247600
    Posts
    481
    Thanks
    26
    Thanked 59 Times in 36 Posts
    Rep Power
    0

    Thumbs up Nen Cache - File cache class

    This class can be used to cache the output of PHP generated pages in files.

    It can capture the output of a PHP script section and cache it by storing the output in files.

    The output data is cached for a given timeout period. While the cache does not expire, the data is retrieved from the cache file.

    The cache file path and the timeout period are configurable.
    Usage : view example.php

    Simple usage :
    PHP Code:
    <?php
    include "nen.class.php";



    $path 'cache/'// We set cache path ! Do not forget '/'
    $cache_adv = new nencache;
    $cache_name='page1'// 
    $cache_time '3600'// (3600s = 1h :D )
    if ($cache_adv -> start ($cache_name,$cache_time,$path)) {

    ///my normal page content here 
    $cache_adv -> build ($path);
    }
    ?>
    I use this class to cache results from mysql query .
    DO not include dinamic ads (e.g. from admob) in this code , because will be cached ..and is not good

    An way to add dinamic ads in cached files can be the usage of some text e.g. [top_admob_ad]
    and on output replace this with admob function :-?


    If you have a better (or not) cache class , please post here .
    Attached Files Attached Files
    Unamos los corazones,hoy todos somos multicolores!

  2. The Following 2 Users Say Thank You to morency For This Useful Post:

    play^ (29-07-11), StRiNg_MaStEr (19-06-11)

  3. #2
    Member
    Join Date
    Oct 2009
    Posts
    98
    Thanks
    36
    Thanked 13 Times in 6 Posts
    Rep Power
    4

    Default

    hw can i specify not cache this content

  4. #3
    Senior Member morency's Avatar
    Join Date
    Oct 2008
    Location
    23.8134710 , 44.3247600
    Posts
    481
    Thanks
    26
    Thanked 59 Times in 36 Posts
    Rep Power
    0

    Default

    PHP Code:
    ///content here will not be cached


    if ($cache_adv -> start ($cache_name,$cache_time,$path)) {

    ///my normal page content here
    /// all content from here will be cached 
    $cache_adv -> build ($path);
    }

    ///content here will not be cached 
    Unamos los corazones,hoy todos somos multicolores!

  5. #4
    Junior Member kafa's Avatar
    Join Date
    Apr 2009
    Location
    Bosnia
    Posts
    12
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    Nice code
    I hope i can implement it into my forum, but one hour seems to be to much for a dynamic site, 5 mins would be a better choice

  6. #5
    Senior Member i0nutzxp's Avatar
    Join Date
    Apr 2009
    Location
    Romania , Galati
    Posts
    153
    Thanks
    7
    Thanked 48 Times in 31 Posts
    Rep Power
    5

    Default

    Just delete the cache file when you add something new.
    <?php unlink('World/Europe/Romania.country'); ?>

  7. #6
    Moderator Anshul's Avatar
    Join Date
    Jun 2007
    Location
    India
    Posts
    296
    Thanks
    5
    Thanked 19 Times in 15 Posts
    Rep Power
    0

    Default

    u cn use memcache also

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Please Help me with Cache
    By Jgutz in forum Snippets, Functions and Classes
    Replies: 6
    Last Post: 25-02-11, 02:26
  2. How to cache using .htaccess trick
    By morency in forum Snippets, Functions and Classes
    Replies: 2
    Last Post: 12-01-11, 17:31
  3. Micro Cache
    By riderz in forum Coding Forum
    Replies: 0
    Last Post: 20-02-10, 19:06
  4. cache emails via php
    By Quintin in forum Coding Forum
    Replies: 4
    Last Post: 28-10-09, 17:24
  5. Having A Problem With No Cache
    By bijaybd in forum Site / Script testing and error fixing
    Replies: 9
    Last Post: 09-11-08, 02:41

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

SEO by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19