Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored constructor to use setSaslAuthData(); #6

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 37 additions & 14 deletions MemcacheSASL.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,13 @@ protected function _recv()
return $array;
}

public function __construct()
public function __construct($user, $password)
{
$this->setSaslAuthData($user, $password);
}

private function setSaslAuthData($user, $password)


public function listMechanisms()
{
$this->_send(array('opcode' => 0x20));
$data = $this->_recv();
return explode(" ", $data['body']);
}

public function setSaslAuthData($user, $password)
{
$this->_send(array(
'opcode' => 0x21,
'key' => 'PLAIN',
Expand All @@ -116,8 +109,18 @@ public function setSaslAuthData($user, $password)
if ($data['status']) {
throw new Exception($data['body'], $data['status']);
}

}


public function listMechanisms()
{
$this->_send(array('opcode' => 0x20));
$data = $this->_recv();
return explode(" ", $data['body']);
}


public function addServer($host, $port, $weight = 0)
{
$this->_fp = stream_socket_client($host . ':' . $port);
Expand Down Expand Up @@ -344,17 +347,37 @@ public function getStats($type = null)
}
return $ret;
}



public function append()
/**
* Appends and replaces the value of the $key and sets its TTL
*
*/
public function append($key, $value, $ttl = 0)
{
$old = $this->get($key);
$new = $value.$old;
return $this->replace($key, $new, $ttl);
}

public function prepend()
public function prepend($key, $value, $ttl = 0)
{
$old = $this->get($key);
$new = $old.$value;
return $this->replace($key, $new, $ttl);
}

public function getMulti()
public function getMulti(array $keys)
{
$list = array();

foreach($keys as $key => $value)
{
array_push($list, $this->get($value));
}

return $list;
}


Expand Down