Campustream 1.0
A social network MQP for WPI
application/tasks/memcache.php
Go to the documentation of this file.
00001 <?php
00002 
00003 group('memcache');
00004 
00005 desc('Flushes the entire Twitpic cache');
00006 task('flush', function($args) {
00007 
00008         $memcache = MemcacheManager::connection();
00009         
00010         echo "Flushing all items from cache...\n";
00011         $memcache->flush();
00012         
00013 });
00014 
00015 desc('Shows which Memcache servers are online and which ones are offline');
00016 task('status', function() {
00017 
00018         $memcache = MemcacheManager::connection();
00019 
00020         $online   = $memcache->getStats();
00021         
00022         include "{$GLOBALS['APPROOT']}application/config/memcache.php";
00023         
00024         foreach( $config as $name => $server ) {
00025                 
00026                 echo str_pad( "{$name} ({$server['host']}): ", 23);
00027                 
00028                 $key = "{$server['host']}:{$server['port']}";
00029                 echo ( isset( $online[$key] ) ? "ONLINE\n" : "OFFLINE\n" );
00030         }
00031 
00032         
00033 
00034 });
00035 
00036 desc('Delete a single memcache key');
00037 task('delete', function($args) {
00038         
00039         force_execution_on(any_web_server);
00040         
00041         $key = array_shift( $args );
00042         if(strlen($key) == 0){ return false; }
00043         
00044         $memcache = MemcacheManager::connection();
00045         
00046         echo "Deleting cache key: $key\n";
00047         
00048         $memcache->delete( $key );
00049         
00050 });
00051 
00052 desc('Retrieves the data stored at a single memcache key');
00053 task('get', function($args) {
00054         
00055         force_execution_on(any_web_server);
00056         
00057         $key = array_shift( $args );
00058         if(strlen($key) == 0){ return false; }
00059         
00060         $memcache = MemcacheManager::connection();
00061         
00062         echo "Retrieving cache key: $key\n";
00063         
00064         $data = $memcache->get( $key );
00065         
00066         print_r($data);
00067         
00068 });