Q:

PHP object question

Excuse what is probably a really basic question but how do I achieve this.
$cache = New Mem;    
$cache->event($event)->delete;

Which is called via the function below. Without the ->delete, it works perfectly fine, but I just need to find a way to call the delete thus inside the function.
class Mem
{
    function event($event)
    {
        global $pdo;
        global $memcached;

        $key = md5(sha1($event) . sha1('events'));

        if ($this->delete)
        {
            return $memcached->delete($key);
        }
        else
        {
            return $memcached->get($key);
        }
    }
}

I hope that makes sense, sorry for my pseudo code basically for the delete part.

A:

You're calling delete as if it were a method within your class - but you have no method called delete...Instead, you should evaluate the $event variable as I'm doing below and determine what action you'll take:
class Mem {

  private $pdo;
  private $memcached;

  public function event($event) {

    $key = md5(sha1($event) . sha1('events')); #from your original code

    switch ($event) {
      case "delete":
        #do delete stuff
        $this->memchached->delete($key);
        break;
      case "add":
        #do add stuff
        break;
    }
  }

}

Update: Following additional questions in comments...
class Event {

  private $key;

  public function __construct($key) {
    $this->key = $key;
  }

  public function delete($key) {
    # do delete
  }

}

