Basic File Caching
OverviewObjectiveLearn the basics of caching data in ProdigyView to helpspeed up your server’s performance.Requirements B...
Follow Along With Code               Example1. Download a copy of the example code at  www.prodigyview.com/source.2. Insta...
Create Cache  Writing a file to cache is relatively simple. All you need is  a key/name and content to put in the cache.  ...
Adding OptionsCache uses the default values that can be set inPVCache::init(). To override those default values, we canpas...
Reading The CacheWith cache that is stored, we need a way of reading it.They key/name used to save the cache will also be ...
The Cache TagBy default, the tag used to identify the cache isremoved, If you want to read the cache tag, pass theoptions ...
Cache Tag Results    Cache TagCache Tag With Explicitly Set Name
Checking ExpirationOh, so that is the tag used for setting the expiration.Wait, how do you check the expiration? Simply pa...
Expiration DateIf you need to pull the expiration date from thefile, PVCache::getExpiration() method will pull the datefor...
Expiration Date Result             Expiration date/time format
Delete CacheThe final step to manipulating the cache is to delete thecache. After it is deleted, accessing cache through t...
Objects And ArrayOne of the coolest features about the cache inProdigyView is the ability to store objects and arrays into...
How to use cache   We know how to read, write, check and delete cache, but   we actually use it? Simple, check then read o...
Challenge!This is an optional challenge to improve youunderstanding of cache.1. Create a page with header , body and foote...
API ReferenceFor a better understanding of cache in ProdigyView, visitthe api by clicking on the link below.PVCache       ...
Upcoming SlideShare
Loading in …5
×

Basic File Cache Tutorial - PHP

1,740 views

Published on

Learn the basics of writing, reading and checking expiration of file cache.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,740
On SlideShare
0
From Embeds
0
Number of Embeds
25
Actions
Shares
0
Downloads
16
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Basic File Cache Tutorial - PHP

  1. 1. Basic File Caching
  2. 2. OverviewObjectiveLearn the basics of caching data in ProdigyView to helpspeed up your server’s performance.Requirements Basic Understanding of CacheEstimated Time12 Minutes
  3. 3. Follow Along With Code Example1. Download a copy of the example code at www.prodigyview.com/source.2. Install the system in an environment you feel comfortable testing in.3. Proceed to examples/system/Cache.php
  4. 4. Create Cache Writing a file to cache is relatively simple. All you need is a key/name and content to put in the cache. 1. Initialize the cache object2. Set the key/name 3. Write content to cache
  5. 5. Adding OptionsCache uses the default values that can be set inPVCache::init(). To override those default values, we canpass in our own options. Set the expiration time in seconds Modify Cache Expiration and the name of the cache
  6. 6. Reading The CacheWith cache that is stored, we need a way of reading it.They key/name used to save the cache will also be usedfor reading it.
  7. 7. The Cache TagBy default, the tag used to identify the cache isremoved, If you want to read the cache tag, pass theoptions in not to remove the tag. Set the option keeping the cache tag Remember to set the cache name if not using the default
  8. 8. Cache Tag Results Cache TagCache Tag With Explicitly Set Name
  9. 9. Checking ExpirationOh, so that is the tag used for setting the expiration.Wait, how do you check the expiration? Simply pass thekey/name of the file to check. Check if the cache has expired by the key Check name and key
  10. 10. Expiration DateIf you need to pull the expiration date from thefile, PVCache::getExpiration() method will pull the datefor you in a string format. Get the expiration in a date format Add the option to use a name for the cache
  11. 11. Expiration Date Result Expiration date/time format
  12. 12. Delete CacheThe final step to manipulating the cache is to delete thecache. After it is deleted, accessing cache through thatkey will return a null.
  13. 13. Objects And ArrayOne of the coolest features about the cache inProdigyView is the ability to store objects and arrays intocache. These data structures will be serialized on entryand unserialized on retrieval.Set the cache key/name Pass array into cache Read the cache as normal and print out key
  14. 14. How to use cache We know how to read, write, check and delete cache, but we actually use it? Simple, check then read or write.1. Check if the cache has expired first 2. If is not expired, return the cache 3. If it has expired, query that database to find your content. 4. Write the content to cache and return it
  15. 15. Challenge!This is an optional challenge to improve youunderstanding of cache.1. Create a page with header , body and footer content in a string.2. Write the header content to cache and set to expire in 3 minutes.3. Write the body content to cache and set to expire in 5 minutes.4. Write the footer content to cache and set to expire in 7 minutes.5. Add new content to each section of the page only after the content has expired.
  16. 16. API ReferenceFor a better understanding of cache in ProdigyView, visitthe api by clicking on the link below.PVCache More TutorialsFor more tutorials, please visit:http://www.prodigyview.com/tutorials www.prodigyview.com

×