Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Balogh committed Oct 16, 2014
1 parent 96662a9 commit 6109755
Show file tree
Hide file tree
Showing 11 changed files with 187 additions and 497 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -14,7 +14,7 @@
],
"require": {
"php": ">=5.4.0",
"adammbalogh/key-value-store": "~0.4.0",
"adammbalogh/key-value-store": "~0.5.0",
"ext-memcached": ">=2.0.0"
},
"require-dev": {
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 7 additions & 10 deletions readme.md
Expand Up @@ -49,6 +49,7 @@ $kvs = new KeyValueStore($adapter);

$kvs->set('sample_key', 'Sample value');
$kvs->get('sample_key');
$kvs->delete('sample_key');
```

# API
Expand All @@ -57,17 +58,13 @@ $kvs->get('sample_key');

# Toolset

| Key | String | Server |
| Key | Value | Server |
|------------------ |---------------------|------------------|
| ✔ delete | ✔ append | ✔ flush |
| ✔ expire | ✔ decrement | |
| ✔ getKeys | ✔ decrementBy | |
| ✔ getTtl | ✔ get | |
| ✔ has | ✔ getValueLength | |
| ✔ persist | ✔ increment | |
| | ✔ incrementBy | |
| | ✔ set | |
| | ✔ setIfNotExists | |
| ✔ delete | ✔ get | ✔ flush |
| ✔ expire | ✔ set | |
| ✔ getTtl | | |
| ✔ has | | |
| ✔ persist | | |

# Support

Expand Down
6 changes: 3 additions & 3 deletions src/Adapter/MemcachedAdapter.php
Expand Up @@ -2,14 +2,14 @@

use AdammBalogh\KeyValueStore\Adapter\MemcachedAdapter\ClientTrait;
use AdammBalogh\KeyValueStore\Adapter\MemcachedAdapter\KeyTrait;
use AdammBalogh\KeyValueStore\Adapter\MemcachedAdapter\ValueTrait;
use AdammBalogh\KeyValueStore\Adapter\MemcachedAdapter\ServerTrait;
use AdammBalogh\KeyValueStore\Adapter\MemcachedAdapter\StringTrait;

class MemcachedAdapter extends AbstractAdapter
{
use ClientTrait, KeyTrait, StringTrait, ServerTrait {
use ClientTrait, KeyTrait, ValueTrait, ServerTrait {
ClientTrait::getClient insteadof KeyTrait;
ClientTrait::getClient insteadof StringTrait;
ClientTrait::getClient insteadof ValueTrait;
ClientTrait::getClient insteadof ServerTrait;
}

Expand Down
20 changes: 8 additions & 12 deletions src/Adapter/MemcachedAdapter/KeyTrait.php
Expand Up @@ -12,6 +12,8 @@ trait KeyTrait
use ClientTrait;

/**
* Removes a key.
*
* @param string $key
*
* @return bool True if the deletion was successful, false if the deletion was unsuccessful.
Expand All @@ -24,6 +26,8 @@ public function delete($key)
}

/**
* Sets a key's time to live in seconds.
*
* @param string $key
* @param int $seconds
*
Expand All @@ -46,22 +50,12 @@ public function expire($key, $seconds)
);
}

/**
* @return array
*
* @throws \Exception
*/
public function getKeys()
{
return $this->getClient()->getAllKeys();
}

/**
* Returns the remaining time to live of a key that has a timeout.
*
* @param string $key
*
* @return int Ttl in seconds
* @return int Ttl in seconds.
*
* @throws KeyNotFoundException
* @throws \Exception
Expand All @@ -79,6 +73,8 @@ public function getTtl($key)
}

/**
* Determines if a key exists.
*
* @param string $key
*
* @return bool True if the key does exist, false if the key does not exist.
Expand All @@ -97,7 +93,7 @@ public function has($key)
}

/**
* Remove the existing timeout on key, turning the key from volatile (a key with an expire set)
* Removes the existing timeout on key, turning the key from volatile (a key with an expire set)
* to persistent (a key that will never expire as no timeout is associated).
*
* @param string $key
Expand Down
2 changes: 2 additions & 0 deletions src/Adapter/MemcachedAdapter/ServerTrait.php
Expand Up @@ -5,6 +5,8 @@ trait ServerTrait
use ClientTrait;

/**
* Removes all keys.
*
* @return void
*
* @throws \Exception
Expand Down
207 changes: 0 additions & 207 deletions src/Adapter/MemcachedAdapter/StringTrait.php

This file was deleted.

0 comments on commit 6109755

Please sign in to comment.