-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
300 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
namespace OramaCloud\Client; | ||
|
||
class Cache | ||
{ | ||
/** | ||
* @var array The cache storage | ||
*/ | ||
private $cache; | ||
|
||
public function __construct() | ||
{ | ||
$this->cache = []; | ||
} | ||
|
||
/** | ||
* Set a value in the cache. | ||
* @param string $key The key under which to store the value. | ||
* @param mixed $value The value to store. | ||
*/ | ||
public function set(string $key, $value): void | ||
{ | ||
$this->cache[$key] = $value; | ||
} | ||
|
||
/** | ||
* Get a value from the cache. | ||
* @param string $key The key of the value to retrieve. | ||
* @return mixed|null The value or null if not found. | ||
*/ | ||
public function get(string $key) | ||
{ | ||
return $this->cache[$key] ?? null; | ||
} | ||
|
||
/** | ||
* Check if the cache has a key. | ||
* @param string $key The key to check. | ||
* @return bool True if the cache has the key, false otherwise. | ||
*/ | ||
public function has(string $key): bool | ||
{ | ||
return isset($this->cache[$key]); | ||
} | ||
|
||
/** | ||
* Delete a value from the cache. | ||
* @param string $key The key of the value to delete. | ||
* @return bool True if the value was successfully deleted, false otherwise. | ||
*/ | ||
public function delete(string $key): bool | ||
{ | ||
if ($this->has($key)) { | ||
unset($this->cache[$key]); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* Clear the cache. | ||
*/ | ||
public function clear(): void | ||
{ | ||
$this->cache = []; | ||
} | ||
|
||
/** | ||
* Get the size of the cache. | ||
* @return int The number of items in the cache. | ||
*/ | ||
public function size(): int | ||
{ | ||
return count($this->cache); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 8 additions & 5 deletions
13
src/QueryParams/Where.php → src/Client/QueryParams/Where.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.