SlideShare a Scribd company logo
1 of 13
Memcache
Overview
Objective

Learn how to use memcache with ProdigyView.

Requirements

 Basic Understanding of Cache
Estimated Time

8 Minutes
Follow Along With Code
               Example
1. 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/Memcache.php
Installing Memcache
In order to use memcache, you must have it installed. Installation
differs on distribution but the basics are this.
 Ubuntu
  1. apt-get install memcached php5-memcahce
  2. pecl install memcache
 Centos
  1. rpm -Uvh
     http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-
     5-3.noarch.rpm
  2. yum install memcached php-pecl-memcache
 Both
  1.   pecl install memcache
  2.   Copy ‘memcache.so’ into your php.ini
  3.   service memcached start
  4.   Restart apache or nginx
Cache Server
 Before we can use memcache, we need to setup our
 memcache servers. Replace the localhost with the server
 you have memcache running on. Multiple memcache
 servers can be added to config array.

1. Set the option for            2. Set the host        3. Set the option to
memcache servers                                        connect to the server to
                                                        true.




             4. Pass the configuration into the init.
Write To Memcache
Writing to memcache is relatively easy. All you need the
key/name of the cache, and the data to pass the cache.
Writing to memcache accepts objects and arrays also.


1. Set the key/name of the cache         2. Pass the data to the cache




                          3. Read data based on key
Set Expiration
   When writing to memcache, the default expiration is set in
   the init. We can override the default expiration by adding
   it into the options.

1.Set the key/name of the cache   2. Set the data        3. Set the expiration




                                           4. Read the cache
Add Only
Add Only is an option that will only write the data to
memcache if it does not exist or the cache has expired. This
can be useful for ensure that only unique values are written
to cache.


                      1. Only write to cache has expired or does not exist




                     2. Read cached value
Replace
Replace is an option that will only replace the cache if it exist
and has not expired. Otherwise nothing its written.


                                      1. Write cache only if it exist




                         2. Read the cached value
Removing Memcache
Removing a value from memcache is accomplished by
using the key that was used to save it. Call the
PVCache::removeCache() method.


              Delete the memcache using the key
Flush Memcache

Flushing the memcache will expire all the data and
subsequently remove all the expired data. There is no key
passed when flushing data, just set the option of flush to
true.

                   Set the option for flushing the memcache
Review
1. Set the memcache servers in the init.
2. Use PVCache::writeMemcache to write to memcache
3. The option add_only will only write to cache if they key
   does not exist while the option replace will only write to
   memcache if the key does exist.

4. Use PVCache::readMemcache to read a stored cached
   value

5. Use PVCache::deleteMemcache to delete the memcache
   associated with a key
API Reference
For a better understanding of cache in ProdigyView, visit
the api by clicking on the link below.

PVCache




                 More Tutorials
For more tutorials, please visit:

http://www.prodigyview.com/tutorials


                       www.prodigyview.com

More Related Content

More from ProdigyView

More from ProdigyView (19)

HTML5 Tags and Elements Tutorial
HTML5 Tags and Elements TutorialHTML5 Tags and Elements Tutorial
HTML5 Tags and Elements Tutorial
 
HTML Forms Tutorial
HTML Forms TutorialHTML Forms Tutorial
HTML Forms Tutorial
 
Html Tags Tutorial
Html Tags TutorialHtml Tags Tutorial
Html Tags Tutorial
 
Video Conversion PHP
Video Conversion PHPVideo Conversion PHP
Video Conversion PHP
 
Sending Email Basics PHP
Sending Email Basics PHPSending Email Basics PHP
Sending Email Basics PHP
 
Tools ProdigyView
Tools ProdigyViewTools ProdigyView
Tools ProdigyView
 
Custom Validation PHP
Custom Validation PHPCustom Validation PHP
Custom Validation PHP
 
Basic File Cache Tutorial - PHP
Basic File Cache Tutorial - PHPBasic File Cache Tutorial - PHP
Basic File Cache Tutorial - PHP
 
Understanding Web Cache
Understanding Web CacheUnderstanding Web Cache
Understanding Web Cache
 
Javascript And CSS Libraries
Javascript And CSS LibrariesJavascript And CSS Libraries
Javascript And CSS Libraries
 
PHP Libraries
PHP LibrariesPHP Libraries
PHP Libraries
 
SQL Prepared Statements Tutorial
SQL Prepared Statements TutorialSQL Prepared Statements Tutorial
SQL Prepared Statements Tutorial
 
Database Basics
Database BasicsDatabase Basics
Database Basics
 
Implementing the Adapter Design Pattern
Implementing the Adapter Design PatternImplementing the Adapter Design Pattern
Implementing the Adapter Design Pattern
 
Intercepting Filters Design Pattern
Intercepting Filters Design PatternIntercepting Filters Design Pattern
Intercepting Filters Design Pattern
 
Creating Dynamic Objects PHP
Creating Dynamic Objects PHPCreating Dynamic Objects PHP
Creating Dynamic Objects PHP
 
PV Standard Search Query
PV Standard Search QueryPV Standard Search Query
PV Standard Search Query
 
Prodigyview XML COnfiguration File
Prodigyview XML COnfiguration FileProdigyview XML COnfiguration File
Prodigyview XML COnfiguration File
 
Learning PHP Basics Part 2
Learning PHP Basics Part 2Learning PHP Basics Part 2
Learning PHP Basics Part 2
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

Memcache Tutorial PHP

  • 2. Overview Objective Learn how to use memcache with ProdigyView. Requirements  Basic Understanding of Cache Estimated Time 8 Minutes
  • 3. Follow Along With Code Example 1. 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/Memcache.php
  • 4. Installing Memcache In order to use memcache, you must have it installed. Installation differs on distribution but the basics are this.  Ubuntu 1. apt-get install memcached php5-memcahce 2. pecl install memcache  Centos 1. rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release- 5-3.noarch.rpm 2. yum install memcached php-pecl-memcache  Both 1. pecl install memcache 2. Copy ‘memcache.so’ into your php.ini 3. service memcached start 4. Restart apache or nginx
  • 5. Cache Server Before we can use memcache, we need to setup our memcache servers. Replace the localhost with the server you have memcache running on. Multiple memcache servers can be added to config array. 1. Set the option for 2. Set the host 3. Set the option to memcache servers connect to the server to true. 4. Pass the configuration into the init.
  • 6. Write To Memcache Writing to memcache is relatively easy. All you need the key/name of the cache, and the data to pass the cache. Writing to memcache accepts objects and arrays also. 1. Set the key/name of the cache 2. Pass the data to the cache 3. Read data based on key
  • 7. Set Expiration When writing to memcache, the default expiration is set in the init. We can override the default expiration by adding it into the options. 1.Set the key/name of the cache 2. Set the data 3. Set the expiration 4. Read the cache
  • 8. Add Only Add Only is an option that will only write the data to memcache if it does not exist or the cache has expired. This can be useful for ensure that only unique values are written to cache. 1. Only write to cache has expired or does not exist 2. Read cached value
  • 9. Replace Replace is an option that will only replace the cache if it exist and has not expired. Otherwise nothing its written. 1. Write cache only if it exist 2. Read the cached value
  • 10. Removing Memcache Removing a value from memcache is accomplished by using the key that was used to save it. Call the PVCache::removeCache() method. Delete the memcache using the key
  • 11. Flush Memcache Flushing the memcache will expire all the data and subsequently remove all the expired data. There is no key passed when flushing data, just set the option of flush to true. Set the option for flushing the memcache
  • 12. Review 1. Set the memcache servers in the init. 2. Use PVCache::writeMemcache to write to memcache 3. The option add_only will only write to cache if they key does not exist while the option replace will only write to memcache if the key does exist. 4. Use PVCache::readMemcache to read a stored cached value 5. Use PVCache::deleteMemcache to delete the memcache associated with a key
  • 13. API Reference For a better understanding of cache in ProdigyView, visit the api by clicking on the link below. PVCache More Tutorials For more tutorials, please visit: http://www.prodigyview.com/tutorials www.prodigyview.com