Giter VIP home page Giter VIP logo

phpsocialnetwork / phpfastcache Goto Github PK

View Code? Open in Web Editor NEW
2.3K 128.0 448.0 21.31 MB

A high-performance backend cache system. It is intended for use in speeding up dynamic web applications by alleviating database load. Well implemented, it can drops the database load to almost nothing, yielding faster page load times for users, better resource utilization. It is simple yet powerful.

Home Page: https://www.phpfastcache.com

License: MIT License

PHP 99.46% Shell 0.50% Batchfile 0.04%
cache php redis couchbase speed website mongodb cassandra driver memcached

phpfastcache's People

Contributors

absfarah avatar bfintal avatar bukowskiadam avatar burlesonbrad avatar bylexus avatar chaegumi avatar dongnan avatar fbonzon avatar geolim4 avatar git-webmaster avatar golodnyi avatar hammermaps avatar jfcherng avatar jomisacu avatar khoaofgod avatar landy2005 avatar lemark0 avatar likemarx avatar marcomiltenburg avatar maximiliankresse avatar nigrosimone avatar r0b- avatar remowashere avatar saiful avatar tilluhlig avatar tobsn avatar unryongpark avatar uprel avatar vincent avatar westy92 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phpfastcache's Issues

Composer issue

I'm trying to download the project with the use of the composer but I always get an error.

I'm using the command:
php composer.phar require "phpfastcache/phpfastcache":*

and I get:
Your requirements could not be resolved to an installable set of packages.

Problem 1
- The requested package phpfastcache/phpfastcache could not be found in any version, there may be a typo in the package name.

Potential causes:

Read http://getcomposer.org/doc/articles/troubleshooting.md for further common problems.

Installation failed, reverting ./composer.json to its original content.

Is this method supported ?

XCache var cache was not initialized properly

Hallo Khoaofgod...

I using cronjob to run php script, but in log error i got this

[04-Jan-2014 12:09:01 Asia/Jakarta] PHP Warning: xcache_get() [function.xcache-get]: XCache var cache was not initialized properly. Check php log for actual reason in /home/xxx/public_html/new/libraries/php_fast_cache.php on line 1114

[04-Jan-2014 12:09:01 Asia/Jakarta] PHP Warning: xcache_set() [function.xcache-set]: XCache var cache was not initialized properly. Check php log for actual reason in /home/xxx/public_html/new/libraries/php_fast_cache.php on line 1105

How to fix it? I am using phpfastcache Revision 620

MySql queries

I couldn't cache mysql queries. Can you show an example pls?

REDIS

Do you plan to implement REDIS ? :) is faster than memcache and APC :)

Support for Redis?

Sorry if this is answered elsewhere, but I do not see any specific support planned for Redis. Do you plan to have support for it in the future?

Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]

Dear Khoaofgod, suddenly in one of my projects, a fatal error displayed, and it cause some sections to be die.
This is the error message:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 5 database is locked' in /home/estqlal/public_html/includes/phpfastcache/drivers/sqlite.php:272 Stack trace: #0 /home/estqlal/public_html/includes/phpfastcache/drivers/sqlite.php(272): PDOStatement->execute(Array) #1 /home/estqlal/public_html/includes/phpfastcache/drivers/sqlite.php(244): phpfastcache_sqlite->deleteRow(Array) #2 /home/estqlal/public_html/includes/phpfastcache/phpfastcache.php(98): phpfastcache_sqlite->driver_get('SidebarArticles', Array) #3 /home/estqlal/public_html/sidebar.php(20): phpFastCache->get('SidebarArticles') #4 /home/estqlal/public_html/index.php(161): require_once('/home/estqlal/p...') #5 {main} thrown in /home/estqlal/public_html/includes/phpfastcache/drivers/sqlite.php on line 272

mail

i see your are using a function to send bug errors via email. this section must be more configurable via public properties such as destination email, using SMTP (some hosting has blocked local smtp to prevent spam attack) i think you could integrate directly to php mailer line $mail = new PHPMailer();... and so on.. user must have phpMailer class in their server. and you should let user to set the path of php mailer class and "include_once" into the function (include files only if needed).

sorry for my bad english.

An error in 5.master.php - line 46

$cache2->setMulti(array("key1","value1", 300),
array("key2","value2", 600),
array("key3","value3", 1800),
);

Maybe the last comma is redundant?

Private methods prevents inheritance

If I want to add some additional options for memcached, like compression it is hard to do because memcached_addserver method is private not protected.

Is it possible to add phpDoc compatibile syntax to each function (public are more important than the others).

[phpfastcache_v2.1_release] sqlite.php: unlink() permission denied

Apache 2.4 PHP 5.4 (Windows Server 2008 x86)

Warning: unlink(C:\...//sqlite/indexing): Permission denied in C:\...drivers\sqlite.php on line 328

I usually see that kind of error when there is a process not releasing the handle of those files.

Step to reproduce

<?php
require_once 'C:\xampp\htdocs\www.test.it\phpfastcache\trunk\phpfastcache_v2.1_release\phpfastcache\phpfastcache.php';

class MyCache extends phpFastCache
{
    private static $istance;
    Private $obCache;

    function __construct()
    {
                $option = array('securityKey' => 'aCache', 'path' => dirname(__FILE__));
        $this->obCache = parent::__construct('sqlite', $option);
    }

    public static function getIstance()
    {
        if( is_null(self::$istance) )
        {
            self::$istance = new self();
        }

        return self::$istance;
    }
}

if( $CacheData = MyCache::getIstance()->get('aKeyword') )
{
    die($CacheData);
}

MyCache::getIstance()->set('aKeyword','aValue', 60*60*24);

MyCache::getIstance()->clean();

echo 'No cache'; 
?>

Persistent cache

The file cache is deleted on server restart. I would like it to remain and honour the expiry I have set which in my case is 28 days.

xcache_cleanup

For me xcache_cleanup gets this error:

Warning: xcache_clear_cache() expects exactly 2 parameters, 1 given in /PATH/TO/FILE/php_fast_cache.php

so i've modified the function like this:

private static function xcache_cleanup($option = array()) {
$cnt = xcache_count(XC_TYPE_VAR);
for ($i=0; $i < $cnt; $i++) {
xcache_clear_cache(XC_TYPE_VAR, $i);
}
return true;
}

and all works file when i call: phpFastCache::cleanup();

Tags

Hello,
Introduction of tags will be?

sqlite (auto mode) stats() returns error

When requesting stats() from the cache object, it returns a error that the table caching does not exist.

(line 303 in sqlite.php)

If I comment those line 303 - 307 the stats() keeps returning 0 for each value in the array.

Reference to $_SERVER on the command line

Hi,

Using the master phpfastcache_v2.1_release/phpfastcache/phpfastcache.php

I get a warning about $_SERVER['HTTP_HOST'] not existing when I use phpfastcache in a command-line php script which I have to fix with:

if (empty($_SERVER['HTTP_HOST'])) { // patch for phpfastcache referencing this
$_SERVER['HTTP_HOST'] = 'localhost';
}

Please could you remove such references or enable them to be set?

X Cache is supported & Bugs Report here

X-Cache have supported.

phpFastCache::$storage = "xcache";

All bugs about x-cache please report here.

AUTO Mode Priority: APC, XCache, MemCached, MemCache, WinCache, PDO, Files

* phpFastCache::$useTmpCache = true; // default is FALSE
// faster checking cache for LOOP Only. If you don't use LOOP, don't spend more memory.
* Example:
* WHILE() {
*   $cache = phpFastCache::get("name");
* }
* LOOP() {
*   $cache = phpFastCache::get("name");
* }
*    --> THE NAME maybe duplicated some times, if you set $useTmpCache it will check from $Tmp first before IT connect to Cache Memory or Open Files to check.
*        Will be faster a little bit if you know what you are doing.

As another topic about auto clean up files cache.
The core right now added auto clean up files cache every 1 hour for "files" cache only.
You can do custom config by:

phpFastCache::$files_cleanup_after = 1; // hours(s)

Let me know if any bugs & issues OR This topic will be close at end of this month.

thanks for sharing

i want to write a simple file cache,find some ideals from your code,thanks

Schedules for Next Version 2.0

Hi guys

I am gonna make next version 2.0

  • The current one is 1.3 will be keep going improve and fix bugs. I will not remove current version on future, and I will keep develop it as one file / one static class for who is using it.
  • The version 2.0 will on schedule working, and will be publish together with current version.

Reason to plan to 2.0 are:

  • One Class can't handle everything. It makes it
    painful to add a new backend (redis, apcu, tokyotyrant, mongodb, ...) or
    modify an existing one.
  • Need responsability in case you want to keep the possibility to have multiple
    backends.
  • Factory method instead, maybe a singleton method if necessary

In design for phpFastCache in my head right now:

  • Not use static any more;
  • phpfastcache_get(); phpfastcache_set();
  • phpfastcache.php
  • phpfastcache_class/apc.php ; wincache.php ; xcache.php .. etc

It easy to add new class, upgrading, bugs, and easy to save memory when u don't need other class loading.

Any ideas reply at this topic.

ip.codehelper.io.php doesn't work

the website codehelper.io is not accessible since several days. Inside the files there is a relation with this website, the add on does'nt wok now.

PDO CHMOD 0777

Hallo
I have a issued about pdo cache.

I created a modul for cron job, in cron job need to create a folder
cache/f011sdfasddsd8efed7as420323c793/ exampled. In these folder will be consist two files they are :
pdo.caching and config.41065cf4fd8asdf 7d52bedfda24a32adf75b1fe0.cache.ini

And I am considering for chmod it 0777 or Writable permission, I am afraid if some body can download these file via browser. I have test and it can be downloaded.

Other modul I set automatically, other module created cache APC, so I look cron job module and others moduls have created different cache, they are still in one application.

How to set chmod not to 0777 but still created pdo cache.

Thanks

regarding usage

hello,
i have downloaded phpfastcache from github..i am not getting the proper way to use it.
i have included
include("php_fast_cache.php");
phpFastCache::$storage = "auto";

i am not understanding few terms being used further like "product_page" and "identity_keyword"

Fallback?

Does the fallback concept work? It doesn't for me. I just get an exception that says "Can't use this driver for your website!" when I try to use memcached with a fallback of files.

Here's my code.

$options = array(
    'fallback' => array(
        'memcached' => 'files'
    )
);
$cache = $cache = new phpFastCache('memcached', $options);

But looking through the phpfastcache code, I don't see any exception catching. Searching for the word fallback seems to result in almost nothing. It doesn't look like it could work.

End of support of APC for PHP 5.5.x and support of OPcache

Dear phpfastcache developers,

With the announcement of the end of support of APC within PHP 5.5.x and its replacement by OPcache, is there any plan to update the library to support OPcache ?

Thanks a lot and best regards,

Alexandre 8)

skype me: khoaofgod

I will clean up the issues soon, because I am opening a forum to do support & continue develop other plugins for wordpress , carts , forum use phpFastCache.

This box gonna do issues only.

Skype me: If you have any problem or need fast support.
Skype: khoaofgod

Error Writable permission!

Hallo Khoafgod...

I am trying phpfascache but I get error "Please re-upload the caching file caching.0777 and chmod it 0777 or Writable permission!"

I am using Mac with Mamp Pro and I have change attribut the caching.0777 writable...
Do you know what exactly my problem?

Thanks

Clear section of cache

I'd like to clear a section of my cache. Say for example that I store data by prefixing it with a namespace. Perhaps I cache some twitter data, facebook data, etc. I might store them as twitter.myvalue1, twitter.myvalue2, and facebook.myvalue1, facebook.myvalue2. How could I delete the cache entries for twitter? And I don't know all the names of the values. It's not necessary myvalue1/2/3/etc, I just know it starts with twitter.

Time Cache....

Hello Khoaofgod...

I want to ask about time of cache..

What do you mean 600 seconds = 5 minutes?

We know that 300 seconds = 5 minutes?

600 seconds = 10 minutes

I think it can make confuse in documentation and uses.

Maybe you have reasons, could you tell me?

Thanks...

Problems on increment, decrement & touch

I was adding a Redis driver when I spotted this:

$object being returned from

   function get($keyword, $option = array()) {
        if($this->is_driver == true) {
            $object = $this->driver_get($keyword,$option);
        } else {
            $object = $this->driver->driver_get($keyword,$option);
        }

        if($object == null) {
            return null;
        }
        return $object['value'];
    }

is not the entire array and only the 'value' so:

    function increment($keyword, $step = 1 , $option = array()) {
        $object = $this->get($keyword);
        if($object == null) {
            return false;
        } else {
            $value = (Int)$object['value'] + (Int)$step;
            $time = $object['expired_time'] - @date("U");
            $this->set($keyword,$value, $time, $option);
            return true;
        }
    }

    function decrement($keyword, $step = 1 , $option = array()) {
        $object = $this->get($keyword);
        if($object == null) {
            return false;
        } else {
            $value = (Int)$object['value'] - (Int)$step;
            $time = $object['expired_time'] - @date("U");
            $this->set($keyword,$value, $time, $option);
            return true;
        }
    }

    function touch($keyword, $time = 300, $option = array()) {
        $object = $this->get($keyword);
        if($object == null) {
            return false;
        } else {
            $value = $object['value'];
            $time = $object['expired_time'] - @date("U") + $time;
            $this->set($keyword, $value,$time, $option);
            return true;
        }
    }

will not work and will also mess up the cached values.

I'm fixing it by passing an option to the get method so it returns the entire array.

Will send a Pull request for both this issue and the Redis driver once resolved and tested.

Release 2.4.1

Release 2.4 will be release on next Monday Feb 02.

What's new

  • Redis supported
    "pecl install redis"
  • Cookie Driver
    Fun for who want to store cache on visitor's browser.
  • Non-Expring Cache for Object
    Example: set("keyword", $data); will be non-expire until you do delete("keyword");
  • Temporary Disabled phpFastCache
    use: phpFastCache::$disabled = true;
    After this line, all get("keyword") will return NULL;
  • Improved Files Cache for Busy Disk
    Busy Disk will skip caching object and continue without error_log problems.
  • Composers will be added
  • Improve fallback
    If specific driver that you set is not available then system will use "files" driver

Then March 03 will be release 2.5:
-- Planned for MongoDB
-- External Server Caching
-- and phpFastSQL.com will be release together.

Cache PATH

Helo Khoafgod...

I want to ask about Cache PATH, I have set cache path to another path but it's still in current directory, how to fixed it?
Example :
phpFastCache::$path = SRV_ROOT.CACHE;// absolute path

I look at Line 162 self::$path = dirname(FILE);
how about if dirname(FILE) change to user defined parameter?

if php_fast_cache.php in my folder directory like library/php_fast_cache.php
so it will create in library folder not in SRV_ROOT.CACHE; (user defined)

Thanks...

phpFastCache::$sys['method'] = "pdo";

I have a "Call to a member function prepare() on a non-object in /php_fast_cache.php on line 1536" Fatal error when trying to: $recentArticles = phpFastCache::get("recentArticles");

This problem disappears when I add a 'phpFastCache::$sys['method'] = "pdo";' line to the code. Why is it so?

Manual cache file deletion?

I just started messing around with this. Works great so far. I was wondering if it's possible to manually delete cache files when you are using filesystem storage as the caching type? I don't see where the cache files are stored on the file system.

There are some cases where I need to manually delete the cache and let my webpage rebuild the cache because a DB query was modified and I can't wait until the cache expires. Is the only way to delete the cache to call $cache->delete()?

Fatal error: Call to a member function prepare()

HI,

I just downloaded the script and tested it, but i am getting this error when testing.php


Caching = auto
SET 1 -->
Fatal error: Call to a member function prepare() on a non-object in /public_html/phpfastcache/php_fast_cache.php on line 1665

I also get this error when trying the script with "auto" selected, works only when set o PDO.

Fatal error: Call to a member function prepare() on a non-object in /public_html/phpfastcache/php_fast_cache.php on line 1575

how can i cache pdo query

how can i solve this code problem?

get("product_page"); if($products == null) { $products = $conn->prepare("SELECT text,time FROM small WHERE active='0' ORDER BY time DESC LIMIT 10"); $products->execute(); $cache->set("product_page",$products , 600); } while($obj = $products->fetch(PDO::FETCH_OBJ)){ ?>
text; ?>
time);} ?>

order for "auto"

Hi, i testing performace for cache aaand
first ist APC (best performace) +- 70ms
sqlite +- 320ms
files +- 70ms

then order is wrong... second sqlite si very slow

Have a question? Feel FREE to post it here

If you have any questions or you need my help, just create a topic here.

I will take care it on couple hours.

You can also skype me: khoaofgod

*** PLEASE do not reply this topic, just create new one ^_^ Thanks, dude.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.