SlideShare a Scribd company logo
Memcache
A high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load
Features Very Fast APIs Hash Table LRU High Performance Slab Allocator
Disadvantages Lacks Access Control Security
1.Installation #Download the extension module apt-get install php5-memcache # Edit /etc/php5/conf.d/memcache.ini and uncomment the following line by removing the semi-colon extension=memcache.so # Restart apache etc/init.d/apache2 restart
Implementation PHP:  <? $memcache =  new  Memcache; $memcache->connect ( 'localhost', 11211 )  or  die   ( &quot;Could not connect&quot; ) ; ?>
Example: $sql = &quot;select * from pages where page_id=1&quot;; $qry =  mysql_query ( $sql )  or  die ( mysql_error () .&quot; : $sql&quot; ) ; $result =  mysql_fetch_object ( $qry ) ;  $content = $result->content;
$sql = &quot;select * from pages where page_id=1&quot;;  $key =  md5 ( 'query'.$sql ) ;  $result = $memcache->get ( $key ) ;  if ( $result ==  null)   {   $qry =  mysql_query ( $sql )  or  die ( mysql_error () .&quot; : $sql&quot; ) ;  if ( mysql_num_rows ( $qry ) > 0 )   { $result  =  mysql_fetch_object ( $qry ) ; $memcache->set ( $key,$result,0,3600 ) ;  } }
Functions Memcache::add Memcache::get Memcache::connect Memcache::delete Memcache::addServer Memcache::close
Memcache::add <?php $memcache_obj = memcache_connect(&quot;localhost&quot;, 11211); $memcache_obj->add('var_key', 'test variable', false, 30); ?>
Memcache::connect <?php $memcache = new Memcache; $memcache->connect('memcache_host', 11211); ?>
Memcache::delete <?php $memcache_obj = new Memcache; $memcache_obj->connect('memcache_host', 11211); $memcache_obj->delete('key_to_delete', 10); ?>
Memcache::get <?php $memcache_obj = new Memcache; $memcache_obj->connect('memcache_host', 11211); $var = $memcache_obj->get('some_key'); ?>
References: http://in.php.net/memcache http://phpbuilder.com/manual/en/intro.memcache.php http://www.hostingcoupons.org/what-is-memcached/
Thank You…

More Related Content

DOCX
Hyperlink
PDF
RESTful web services
PPTX
16.mysql stored procedures in laravel
ODP
Mojolicious on Steroids
PDF
Developing apps using Perl
KEY
Mojolicious - A new hope
PPTX
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
PDF
Mojolicious, real-time web framework
Hyperlink
RESTful web services
16.mysql stored procedures in laravel
Mojolicious on Steroids
Developing apps using Perl
Mojolicious - A new hope
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
Mojolicious, real-time web framework

What's hot (20)

PDF
Como construir uma Aplicação que consuma e produza updates no Twitter usando ...
PDF
Inside Bokete: Web Application with Mojolicious and others
PPT
New: Two Methods of Installing Drupal on Windows XP with XAMPP
PDF
Selenium sandwich-2
PDF
PHP and Databases
PDF
Secure Coding with WordPress - WordCamp SF 2008
PDF
Selenium Sandwich Part 1: Data driven Selenium
TXT
PPTX
19.imagini in laravel5
PDF
Phinx talk
PDF
Databases and MySQL
PDF
Extending the WordPress REST API - Josh Pollock
PPTX
Oracle APEX Performance
PDF
Prefixルーティングとthemeのススメ
DOC
Creating a Simple PHP and MySQL-Based Login System
PDF
Entry-level PHP for WordPress
PPTX
An introduction to Laravel Passport
PDF
PDF
Using Renderless Components in Vue.js during your software development.
PPTX
HackU PHP and Node.js
Como construir uma Aplicação que consuma e produza updates no Twitter usando ...
Inside Bokete: Web Application with Mojolicious and others
New: Two Methods of Installing Drupal on Windows XP with XAMPP
Selenium sandwich-2
PHP and Databases
Secure Coding with WordPress - WordCamp SF 2008
Selenium Sandwich Part 1: Data driven Selenium
19.imagini in laravel5
Phinx talk
Databases and MySQL
Extending the WordPress REST API - Josh Pollock
Oracle APEX Performance
Prefixルーティングとthemeのススメ
Creating a Simple PHP and MySQL-Based Login System
Entry-level PHP for WordPress
An introduction to Laravel Passport
Using Renderless Components in Vue.js during your software development.
HackU PHP and Node.js
Ad

Viewers also liked (11)

PPT
Introduction to JQuery
PDF
Ehcache Architecture, Features And Usage Patterns
PDF
The MobME Story - March 2010
PPT
Computer Hardware
PDF
Introduction to Ruby
PPTX
Ppt of prannav[startup village]
PDF
The Chillr Story - Evolution of a startup from Telecom to FinTech
PPT
How to set up and Configure Kannel, A quick start
PPTX
GREEN KERALA
PPT
Web Server Load Balancer
PPTX
Startup village
Introduction to JQuery
Ehcache Architecture, Features And Usage Patterns
The MobME Story - March 2010
Computer Hardware
Introduction to Ruby
Ppt of prannav[startup village]
The Chillr Story - Evolution of a startup from Telecom to FinTech
How to set up and Configure Kannel, A quick start
GREEN KERALA
Web Server Load Balancer
Startup village
Ad

Similar to Memcache (20)

PDF
Memcached Study
PPT
Php MySql For Beginners
PPT
P H P Part I I, By Kian
PPT
Ubi comp27nov04
PPT
Zend Con 2008 Slides
PPT
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PPT
Php frameworks
PPT
General Principles of Web Security
PDF
Ch ch-changes cake php2
PDF
Pecl Picks
PPT
Download It
ODP
Exploring Symfony's Code
PDF
4069180 Caching Performance Lessons From Facebook
PPTX
Scalling web applications using memcache
PDF
Dutch php conference_apc_mem2010
PDF
PECL Picks - Extensions to make your life better
PDF
Facebook的缓存系统
PPT
Speeding up Page Load Times by Using the Starling Queue Server
ODP
Caching and tuning fun for high scalability @ FOSDEM 2012
PPT
jQuery Performance Rules
Memcached Study
Php MySql For Beginners
P H P Part I I, By Kian
Ubi comp27nov04
Zend Con 2008 Slides
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
Php frameworks
General Principles of Web Security
Ch ch-changes cake php2
Pecl Picks
Download It
Exploring Symfony's Code
4069180 Caching Performance Lessons From Facebook
Scalling web applications using memcache
Dutch php conference_apc_mem2010
PECL Picks - Extensions to make your life better
Facebook的缓存系统
Speeding up Page Load Times by Using the Starling Queue Server
Caching and tuning fun for high scalability @ FOSDEM 2012
jQuery Performance Rules

Recently uploaded (20)

PPT
Teaching material agriculture food technology
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
KodekX | Application Modernization Development
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Cloud computing and distributed systems.
Teaching material agriculture food technology
Review of recent advances in non-invasive hemoglobin estimation
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
MYSQL Presentation for SQL database connectivity
Building Integrated photovoltaic BIPV_UPV.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
KodekX | Application Modernization Development
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Network Security Unit 5.pdf for BCA BBA.
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Unlocking AI with Model Context Protocol (MCP)
Diabetes mellitus diagnosis method based random forest with bat algorithm
Chapter 3 Spatial Domain Image Processing.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Cloud computing and distributed systems.

Memcache