• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Memcache Tutorial PHP
 

Memcache Tutorial PHP

on

  • 7,584 views

Learn how to install memcache and use it with ProdigyView.

Learn how to install memcache and use it with ProdigyView.

Statistics

Views

Total Views
7,584
Views on SlideShare
7,555
Embed Views
29

Actions

Likes
3
Downloads
61
Comments
0

2 Embeds 29

http://www.prodigyview.com 27
http://www.slashdocs.com 2

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Memcache Tutorial PHP Memcache Tutorial PHP Presentation Transcript

    • Memcache
    • OverviewObjectiveLearn how to use memcache with ProdigyView.Requirements Basic Understanding of CacheEstimated Time8 Minutes
    • 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/Memcache.php
    • Installing MemcacheIn order to use memcache, you must have it installed. Installationdiffers 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 tomemcache servers connect to the server to true. 4. Pass the configuration into the init.
    • Write To MemcacheWriting to memcache is relatively easy. All you need thekey/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 OnlyAdd Only is an option that will only write the data tomemcache if it does not exist or the cache has expired. Thiscan be useful for ensure that only unique values are writtento cache. 1. Only write to cache has expired or does not exist 2. Read cached value
    • ReplaceReplace is an option that will only replace the cache if it existand has not expired. Otherwise nothing its written. 1. Write cache only if it exist 2. Read the cached value
    • Removing MemcacheRemoving a value from memcache is accomplished byusing the key that was used to save it. Call thePVCache::removeCache() method. Delete the memcache using the key
    • Flush MemcacheFlushing the memcache will expire all the data andsubsequently remove all the expired data. There is no keypassed when flushing data, just set the option of flush totrue. Set the option for flushing the memcache
    • Review1. Set the memcache servers in the init.2. Use PVCache::writeMemcache to write to memcache3. 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 value5. Use PVCache::deleteMemcache to delete the memcache associated with a key
    • 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