Code Monkey home page Code Monkey logo

simple-php-cache's People

Contributors

alphamarket avatar cosenary avatar open768 avatar rpnzl 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

simple-php-cache's Issues

Composer Package

Can we have this available via Composer. It would help me better manage the packages.

Thanks.

What unit of time is the expiration.

I want to store data for a specific period but am not really sure the unit of time the store method expects
store($key, $data, <$expiration>);
Wondering if the expiration is in seconds, milliseconds. Not really sure

expiration time not working !

i Created a php file and run this code to grab a json and store in .cache file,
Everytime i refresh the php page, cache is also refreshed,

So Now shall I read the json data from the php file or from the .cache file to save api limits ?

function isCached() and expiration

Hi cosenary,
After using your lib for a while I realized that the function _checkExpired should be include in isCached function in order to check whether the cache is expired or not.
Am I right or wrong?

PHP-File-Cache - Modern, maintained and secure alternative to Simple-PHP-Cache

https://github.com/Wruczek/PHP-File-Cache

I loved Simple-PHP-Cache, its small and portable, fits everywhere and is very simple.
But the code is old, buggy and unmaintained.
I have released a full rewrite inspired by this library, called PHP-File-Cache.

It's similar to Simple-PHP-Cache, but also improved drastically.

  • Extended with many handy functions like refreshIfExpired
  • Light, standalone and simple
  • All code in one file - no pointless drivers.
  • Secure - direct cache file access is impossible
  • Well documented and tested
  • Supports PHP 5.4.0 - 7.1+
  • Free under a MIT license

Hope it helps someone.

Cache expiration does not seems to work

Tried creating a cache with 5 minutes expiration but it does not seems to update the new value after 5 minutes.

example:

$cache->setCache('title');
$cache->eraseExpired();

if ( $cache->isCached('main-header') ) {
  print_r($cache->retrieve('main-header'))
} else {
  $cache->store('main-header', "new header title", 360000);
}

How can I cache database results in a loop?

Hi, I just came across this library today and I'm planning on implementing it on a project that I'm currently working on. The new project is essentially a new blogging app that retrieves and displays posts from the database, as you would expect. Problem is that it queries the database on every refresh even if there's no new data to be shown, which is why I want to go the caching route.

I've had a little play with this and I found that only the last data that's returned is cached, which is not what I want, so I literally have the last blog post displaying itself 6 times. I just want to ask: is there a way to cache data in a loop, properly?

consider adding composer.json

{
    "name": "cosenary/Simple-PHP-Cache",
    "type": "library",
    "require": {
        "php": ">=5.2.0"
    },
    "autoload": {
        "classmap": [
            "."
        ]
    }
}

There are more variables to add, but this is the basics :) I would like to implement this with composer.

cache class not work in php loops

I Put cache class into foreach loops but cache class only add/set one data into cache file.
code:

foreach($_POST['audio'] as $audio){
SQL::put("INSERT INTO " . NEWS_FILES . " (news_id, url, type) VALUES (?, ?, ?)", $id, $audio,"audio");
$c->store($id, array(
'action' => array(
$id, $video,"audio")
));
}
cache File:

{"202":{"time":1410452801,"expire":0,"data":{"action":[202,"http://localhost/user/uploads/files/1/thumbs/1/audio/download-kid-photo-c.jpg","audio"]}}}

I have 4 files for id 202 But cache class insert only one files in file. how to fix this?

Serializing error when using retrieve($key, true)

Thanks for this wonderful and simple caching library. It's exactly what I need!

Just FYI, this notice occurs on line 105 of cache.class.php in my version
of PHP, 5.6.14.

The fix is to only serialize when $type == 'data'. My quick fix was this:

 /**
   * Retrieve cached data by its key
   * 
   * @param string $key
   * @param boolean [optional] $timestamp
   * @return string
   */
  public function retrieve($key, $timestamp = false) {
    $cachedData = $this->_loadCache();
    (false === $timestamp) ? $type = 'data' : $type = 'time';
    if (!isset($cachedData[$key][$type])) return null; 

    if ($type == 'time') {
        return $cachedData[$key][$type];
    }
    return unserialize($cachedData[$key][$type]);
  }

Cache stores only ONE value

When I call store(), only the first value is stored. It happens in a AWS instance, but not in my XAMPP.

I can clear the cache and write again a different data, but only the first one.

Any Idea?

How does the expiration time work?

Is it measured in seconds, milliseconds, minutes, hours? If I set $c->store('text', 'Hello', 5000) will that cache be stored for 5 seconds before expiring? After it expires, does it get deleted?

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.