Skip to content

Commit

Permalink
Merge branch 'release/v0.5.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
betterthanclay committed Aug 22, 2024
2 parents 81ddcb9 + d096120 commit 3eaf8bf
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 26 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v0.5.8 (2024-08-21)
* Converted consts to protected PascalCase
* Updated Veneer dependency and Stub

## v0.5.7 (2024-07-17)
* Updated Veneer dependency

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
"php": "^8.1",

"decodelabs/archetype": "^0.3",
"decodelabs/atlas": "^0.11.1",
"decodelabs/atlas": "^0.12",
"decodelabs/coercion": "^0.2.6",
"decodelabs/dictum": "^0.6.0",
"decodelabs/exceptional": "^0.4.3",
"decodelabs/glitch-support": "^0.4",
"decodelabs/veneer": "^0.11.1",
"decodelabs/veneer": "^0.11.6",

"psr/cache": "^3.0",
"psr/simple-cache": "^3.0",
"nesbot/carbon": "^2|^3"
},
"require-dev": {
"decodelabs/dovetail": "^0.2",
"decodelabs/genesis": "^0.8",
"decodelabs/genesis": "^0.9",
"decodelabs/phpstan-decodelabs": "^0.6",

"ext-memcached": "^3.2",
Expand Down
4 changes: 2 additions & 2 deletions src/Stash/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

class Context
{
public const DRIVERS = [
protected const Drivers = [
'Memcache', 'Redis', 'Apcu', 'Predis', 'PhpFile', 'PhpArray'
];

Expand Down Expand Up @@ -150,7 +150,7 @@ public function load(
public function loadDriverFor(
string $namespace
): Driver {
$drivers = self::DRIVERS;
$drivers = self::Drivers;

if (null !== ($driverName = $this->getConfig()?->getDriverFor($namespace))) {
array_unshift($drivers, $driverName);
Expand Down
14 changes: 7 additions & 7 deletions src/Stash/Driver/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class File implements Driver
{
use KeyGenTrait;

public const KEY_SEPARATOR = '/';
public const EXTENSION = '.cache';
protected const KeySeparator = '/';
protected const Extension = '.cache';

protected Dir $dir;
protected int $dirPerms = 0770;
Expand Down Expand Up @@ -233,7 +233,7 @@ public function delete(
}

if ($key['self']) {
$this->dir->deleteFile($root . static::EXTENSION);
$this->dir->deleteFile($root . static::Extension);
}

return true;
Expand Down Expand Up @@ -316,7 +316,7 @@ protected function getFile(
string $key
): FileInterface {
$key = $this->createKey($namespace, $key);
$key = $this->hashKey($key) . static::EXTENSION;
$key = $this->hashKey($key) . static::Extension;
return $this->dir->getFile($key);
}

Expand All @@ -339,15 +339,15 @@ protected function hashKey(
string $key
): string {
$key = trim($key, '/');
$parts = explode(static::KEY_SEPARATOR, $key);
$parts = explode(static::KeySeparator, $key);

foreach ((array)$parts as &$part) {
if ($part !== '') {
$part = md5((string)$part);
}
}

return implode(static::KEY_SEPARATOR, $parts);
return implode(static::KeySeparator, $parts);
}


Expand Down Expand Up @@ -388,6 +388,6 @@ public function purge(): void
*/
protected function getKeySeparator(): string
{
return static::KEY_SEPARATOR;
return static::KeySeparator;
}
}
2 changes: 1 addition & 1 deletion src/Stash/Driver/PhpFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class PhpFile extends File
{
public const EXTENSION = '.php';
protected const Extension = '.php';

/**
* Store item data in file
Expand Down
16 changes: 8 additions & 8 deletions src/Stash/FileStore/Generic.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

class Generic implements FileStore
{
public const EXTENSION = '.cache';
protected const Extension = '.cache';

protected string $prefix = 'c-';
protected string $namespace;
Expand Down Expand Up @@ -197,7 +197,7 @@ public function scanOlderThan(

foreach ($this->dir->scanFiles() as $name => $file) {
if (!$file->hasChangedIn($ttl)) {
$name = substr($name, strlen($this->prefix), -strlen(self::EXTENSION));
$name = substr($name, strlen($this->prefix), -strlen(self::Extension));
$output[$name] = $file;
}
}
Expand All @@ -213,7 +213,7 @@ public function scanBeginningWith(
$output = [];

foreach ($this->dir->scanFiles() as $name => $file) {
$name = substr($name, strlen($this->prefix), -strlen(self::EXTENSION));
$name = substr($name, strlen($this->prefix), -strlen(self::Extension));

if (substr($name, 0, $length) === $prefix) {
$output[$name] = $file;
Expand All @@ -229,7 +229,7 @@ public function scanMatches(
$output = [];

foreach ($this->dir->scanFiles() as $name => $file) {
$name = substr($name, strlen($this->prefix), -strlen(self::EXTENSION));
$name = substr($name, strlen($this->prefix), -strlen(self::Extension));

if (preg_match($pattern, $name)) {
$output[$name] = $file;
Expand All @@ -242,15 +242,15 @@ public function scanMatches(
public function scanAll(): iterable
{
foreach ($this->dir->scanFiles() as $name => $file) {
$name = substr($name, strlen($this->prefix), -strlen(self::EXTENSION));
$name = substr($name, strlen($this->prefix), -strlen(self::Extension));
yield $name => $file;
}
}

public function scanKeys(): iterable
{
foreach ($this->dir->scanFiles() as $name => $file) {
yield substr($name, strlen($this->prefix), -strlen(self::EXTENSION));
yield substr($name, strlen($this->prefix), -strlen(self::Extension));
}
}

Expand Down Expand Up @@ -375,7 +375,7 @@ public function deleteMatches(
$output = 0;

foreach ($this->dir->scanFiles() as $name => $file) {
$name = substr($name, strlen($this->prefix), -strlen(self::EXTENSION));
$name = substr($name, strlen($this->prefix), -strlen(self::Extension));

if (preg_match($pattern, $name)) {
$output++;
Expand Down Expand Up @@ -464,7 +464,7 @@ protected function normalizeKey(
protected function createKey(
string $key
): string {
return $this->prefix . $this->normalizeKey($key) . self::EXTENSION;
return $this->prefix . $this->normalizeKey($key) . self::Extension;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Stash/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
class Item implements CacheItem
{
public const LOCK_TTL = 30;
public const LockTTL = 30;

protected string $key;

Expand Down Expand Up @@ -441,7 +441,7 @@ public function lock(
$date->add(Coercion::toDateInterval($ttl));
$expires = $date->getTimestamp();
} else {
$expires = time() + static::LOCK_TTL;
$expires = time() + static::LockTTL;
}

return $this->store->getDriver()->storeLock(
Expand Down
5 changes: 2 additions & 3 deletions stubs/DecodeLabs/Stash.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ class Stash implements Proxy
{
use ProxyTrait;

const VENEER = 'DecodeLabs\\Stash';
const VENEER_TARGET = Inst::class;
const DRIVERS = Inst::DRIVERS;
const Veneer = 'DecodeLabs\\Stash';
const VeneerTarget = Inst::class;

public static Inst $instance;

Expand Down

0 comments on commit 3eaf8bf

Please sign in to comment.