Skip to content

Commit

Permalink
Update README.md (#16)
Browse files Browse the repository at this point in the history
* Update README.md

* Run new fixers
  • Loading branch information
marvin255 committed Jun 8, 2024
1 parent 5db3725 commit 54153ce
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ $defaultTTL = 60; // 60 seconds as default TTL

$inMemoryCache = new InMemoryCache($maxCacheSize, $defaultTTL);
$redisCache = new MyAwesomeRedisCache();
$decorator = CompositeCache($inMemoryCache, $redisCache);
$decorator = new CompositeCache($inMemoryCache, $redisCache);

$decorator->get('test'); // this get will trigger a request to redis and save data to memory
$decorator->get('test'); // this get won't trigger any requests and just return data from memory
Expand Down
2 changes: 1 addition & 1 deletion docker/php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN docker-php-ext-install zip opcache \
&& echo 'xdebug.mode=coverage' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini


RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --version=2.5.8 \
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --version=2.7.6 \
&& mkdir -p /.composer && chmod -Rf 777 /.composer


Expand Down
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
</errorLevel>
</PropertyNotSetInConstructor>
<MixedAssignment errorLevel="suppress"/>
<MissingClassConstType errorLevel="suppress"/>
</issueHandlers>

<plugins>
Expand Down
4 changes: 2 additions & 2 deletions src/CompositeCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function get(string $key, mixed $default = null): mixed
/**
* {@inheritDoc}
*/
public function set(string $key, mixed $value, int|\DateInterval $ttl = null): bool
public function set(string $key, mixed $value, int|\DateInterval|null $ttl = null): bool
{
return $this->heavyCache->set($key, $value, $ttl)
&& $this->lightCache->set($key, $value, $ttl);
Expand Down Expand Up @@ -82,7 +82,7 @@ public function getMultiple(iterable $keys, mixed $default = null): iterable
/**
* {@inheritDoc}
*/
public function setMultiple(iterable $values, int|\DateInterval $ttl = null): bool
public function setMultiple(iterable $values, int|\DateInterval|null $ttl = null): bool
{
return $this->heavyCache->setMultiple($values, $ttl)
&& $this->lightCache->setMultiple($values, $ttl);
Expand Down
8 changes: 4 additions & 4 deletions src/InMemoryCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class InMemoryCache implements CacheInterface
public function __construct(
private readonly int $stackSize = self::DEFAULT_STACK_SIZE,
private readonly int $defaultTTL = self::DEFAULT_TTL,
Timer $timer = null
?Timer $timer = null
) {
if ($this->stackSize < 1) {
throw new InvalidArgumentException('Stack size must be greater than 0');
Expand All @@ -52,7 +52,7 @@ public function get(string $key, mixed $default = null): mixed
/**
* {@inheritDoc}
*/
public function set(string $key, mixed $value, int|\DateInterval $ttl = null): bool
public function set(string $key, mixed $value, int|\DateInterval|null $ttl = null): bool
{
if (\count($this->stack) >= $this->stackSize) {
$this->clearStack();
Expand Down Expand Up @@ -100,7 +100,7 @@ public function getMultiple(iterable $keys, mixed $default = null): iterable
/**
* {@inheritDoc}
*/
public function setMultiple(iterable $values, int|\DateInterval $ttl = null): bool
public function setMultiple(iterable $values, int|\DateInterval|null $ttl = null): bool
{
foreach ($values as $key => $value) {
$this->set((string) $key, $value, $ttl);
Expand Down Expand Up @@ -132,7 +132,7 @@ public function has(string $key): bool
/**
* Counts time till cached item is valid.
*/
private function createValidTill(null|int|\DateInterval $ttl): int
private function createValidTill(int|\DateInterval|null $ttl): int
{
$validTill = $this->timer->getCurrentTimestamp();

Expand Down

0 comments on commit 54153ce

Please sign in to comment.