Discussion on 3S Caching System (Cache API results and PHP data)


yougapi supports this item


20 comments found.


Is the caching limited to the 3 sites you posted?

I assume as long as the returned data is xml/json it will work, right?


Well, i meant feeds OTHER than youtube, twitter, facebook.

I intend to cache return API calls from tweetmeme, dig, and other sites. I’ll go ahead and grab it anyway. Gives me something to play with if I can’t use it in my project.


It’s not reserved for xml or json feeds coming from YouTube, Twitter or Facebook. It can be any xml or json feed ;)

ok, thanks. Purchased and playing with it now.

Thanks for the quick responses!

Quick recommendation: I’d also add support for APC and Memcache. It’s even easier than the current methods you have, and generally a better option (depending on the setup and specific needs – but that’s up to the client).

Thanks for the suggestion.

nice script again :) i have some question. can i delete cache file on specific time?

You can define an expiration date for the caching data (ex: 1h, 1day etc). And if you need to delete all the cached data there is a function that you can call that will do it.

Pre purchase question..

Do you still offer support on this item.

I offer support on all my items ;)

i dont get what file to upload?

Should be the whole “3s_caching” caching folder.

ok i did that and set the configuration but i dont get the Caching and retrieving data part do i add code to a file or do i just edit something i want all my callbacks from facebook and my php data all cached for 1 day

Please try threading your comments, by using the reply button (situated in your first comment) instead of creating a new thread. Did you try the demo? Is it working correctly?

and in my header.php file i put include_once(‘3s_caching/Yp_cache.php’);

Note that just including the class in your header will not magically cache your content. You need to define the data you want to cache and pass it to the class, then using the class method to retrieve the cached data. The documentation and included demo file should show you the mechanism.

i dont get this at all can you help explain how to set this up in more detail the pdf file is not clear and the demo.php i dont get.. what do i add this info to the Yp_cache.php

Please contact me by email using my profile page with a temporary FTP and details about what you don’t get exactly. Did you try the demo file and see how the caching of data and retrieving of data works?

ok message sent. did you get it?

Hi yougapi!

I have several questions for you:

1) When caching an object, is “expire” a required option? If i don’t set it, will my object be cached indefinitely?

2) If I use a file system storage : is the “key” option will be the filename?

3) When i call for a cached data by using the command: $data = $c1->cache_get(array(‘key’=>‘123’)); How your script manage expired cache? Is it rebuild automaticaly or do i have to check it before calling cached data?

4) I’m using an API from what I get data. There’s actually +100 000 items available. And each item have about 10 subitems + data coming from my database (informations saved by users). Is your script compatible with this data amount? What’s the best way to store all of this informations : mysql, file system?

I’m sorry for all this questions but I want to be sure of my future caching system!


1. Expire is optional, if not set the data will stay indefinitely.

2. Yes, the key is used in the file name.

3. If it’s expired it will not return any data.

4. I use this script to cache hundreds of thousands of data, and I am using the file system that’s faster than the 2 others.

thank you for your answers, yougapi!

One last question please : is it possible to define cached data in a subdomain, for example : cache.mydomain.com?

I will build a mobile version later. So i’d like to share cached data with them.

This system can be used on any domain or subdomain. It doesn’t relate on the domain to work.

Hi yougapi,

I just have bought your script but i cannot make it working with JSON and XML data (only with plain text). Here is a part of my code :

$jsonUrl = "http://www.myAPIurl";
$json = json_decode($jsonUrl);

$c1 = new Yp_cache();
$c1->cache_set(array('key'=>'12345', 'data'=>$json, 'type'=>'TYPE1', 'expire'=>0));

I don’t have any error message but json result is not cached. If I set value “Test cache” for the $json variable, the file cache is generated.

Could you please tell me how to solve this issue?

Thank you in advance!

I don’t see any json result in your code, you are just giving a URL . And you are passing that URL (which is just a text) to the “json_decode” function, which has no effect since that function is expecting json formated data, and not just a URL ;)

Forget it!

With file_get_contents php function, cache file is greatly generated! I was confused with my previous cache solution…

Have a nice day!

Oki cool, please don’t forget to rate my item! Note also that you can thread your comments by using the reply button at the bottom of your first posted comment ;)

After playing with this script since 4 days, it work like a charm!

Thank you yougapi!

The only thing I see missing right away is the ability to set and get the file and sql storage directories. Hard coding these paths inside the 32_caching folder wasn’t ideal for me, so I extended the Yp_cache class to allow these to be set and get after instantiation. Otherwise, great work.

Glad to hear it, thanks for the feedback :)

If anyone else is interested in this bit of code, here is a link http://pastebin.com/EpjEY4Tk

do you example of caching from your ‘YouTube API Ultimate Integration’?
I aware on high traffic on my video portal.

Not sure what you mean. If this script can be used to cache data coming from YouTube? yes sure

1. I had your script ‘YouTube API Ultimate Integration’
2. I want to use some caching system to reduct traffic to youtube
3. I am not sure how I can integrate ‘3S Caching System’ to ‘YouTube API Ultimate Integration’ then I ask for example of it,I am not sure ‘3S Caching System’ have that example (I don’t want to a lot of modify by myself).
amyway,I just found youtube v.2 can be deprecation https://developers.google.com/youtube/youtube-api-list
hope you have API V.3 for us.
thanks for make great tools

Please contact me through my profile page for that kind of customization requests for a price estimate, thanks

Hi yougapi, does it also create a gzip file for the page? Can it be implemented in this wallpaper script ? Demo – http://www.newmoonwallpaper.com/ Thank you!

It’s not using gzip, but MySQL, SQLite or file systems to store the cached information. I don’t know about that wallpaper script sorry


I obtain an PHP Notice: Undefined index: type in Yp_cache_file.php on line 18

Do you have a solution?

2) How to use a multiple cache on the same page?




1. You need to disable the display of Notices from your server config file 2. You just need to setup different variable name for each one ;)

In fact, I can use :
$data = $c1->cache_get(array('key' => 'city', 'type' => '1'));
if($data===false) {
  $data = mysql_query_fetch_all_assoc("SELECT * FROM `table`");
  $c1->cache_set(array('key' => 'city', 'data' => $data, 'type' => '1', 'expire' => '60'));

$data2 = $c1->cache_get(array('key' => 'city', 'type' => '2'));
if($data2===false) {
  $data2 = mysql_query_fetch_all_assoc("SELECT * FROM `table`");
  $c1->cache_set(array('key' => 'city', 'data' => $data2, 'type' => '2', 'expire' => '120'));

Do you confirm?

Thanks again! Mick


I think that I am in the same situation as digidave0205

In fact, I would like to indicate the folder of cache (for file) like this:

include_once (“Yp_cache.php”); $c1 = new Yp_cache (); $file = “../cache/”;

But, how to use this class with your script ? http://pastebin.com/EpjEY4Tk

Is there another solution?

Thanks again!


I don’t know about that class. But my script doesn’t support specifying folders name since it can also store the cached data in a database. You can use a different key for each cached data, or use the type to differentiate data that are using the same key

What supports PHP 5.4 and 5.6

Supporting both version and all PHP version > 5

What can be tried in localhost? why the result is this: Notice: Undefined index: yp_caching_storage in C:\xampp\htdocs\3\cache\Yp_cache.php on line 4

Notice: Undefined index: yp_caching_storage in C:\xampp\htdocs\3\cache\Yp_cache.php on line 5

Notice: Undefined index: yp_caching_storage in C:\xampp\htdocs\3\cache\Yp_cache.php on line 6

Your server is configured to display notices, that why. Than can be hidden by declaring this at the top of your php files

error_reporting(E_ALL ^ E_NOTICE);

I have sent an email to my question