From 372d62e0bbab5bcfac6404dc912040b038a3afb7 Mon Sep 17 00:00:00 2001 From: Georges Date: Sat, 13 Jan 2024 07:26:00 +0100 Subject: [PATCH] =?UTF-8?q?Updated=20of=20DriverStatistic.=20After=20almos?= =?UTF-8?q?t=208=20years=20untouched=20=F0=9F=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 11 ++++- composer.json | 1 + lib/Phpfastcache/Entities/DriverStatistic.php | 49 +++++++++++++++++-- lib/Phpfastcache/ExtensionManager.php | 2 +- 4 files changed, 57 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a6001e5..f818e3d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## 9.2.3 +##### 11 january 2024 +- __Drivers__ + - **Added support of `Ravendb` as an extension with its own [sub-repository](https://github.com/PHPSocialNetwork/ravendb-extension).** + - Deprecated `\Phpfastcache\Entities\DriverStatistic::getData()`. Will be removed as of v10. + - Deprecated `\Phpfastcache\Entities\DriverStatistic::setData()`. Will be removed as of v10. + - Added `\Phpfastcache\Entities\DriverStatistic::getCount(): int|null`. If applicable will return the count of cache objects stored in driver database/collection. Null otherwise. + - Added `\Phpfastcache\Entities\DriverStatistic::setCount()` + ## 9.2.2 ##### 11 january 2024 - __Core__ @@ -14,7 +23,7 @@ - Upgraded Phpfastcache API to `4.3.0` ([see changes](CHANGELOG_API.md)) - __Extensions__ (💡 New in 9.2) - Created an extension mechanism to allow some drivers to be loaded independently, see [README.md](README.md) - - Created extension for `Couchbasev4` support to its own [sub-repository](https://github.com/PHPSocialNetwork/couchbasev4-extension). + - Added support of `Couchbasev4` as an extension with its own [sub-repository](https://github.com/PHPSocialNetwork/couchbasev4-extension). - **IMPORTANT**: *AS OF v9.2* the following drivers has been **MOVED** to their own sub-repositories as a standalone extension: `Arangodb`, `Couchdb`, `Dynamodb`, `Firestore`, `Mongodb`, `Solr`. However `Couchbasev3` will stay in the core for compatibility reasons but will be deprecated. - **IMPORTANT**: *AS OF v10* extensions will have their namespaces permanently moved from `Phpfastcache\Drivers\EXT_NAME\{Config, Driver, Event, Item}` to `Phpfastcache\Extensions\Drivers\EXT_NAME\{Config, Driver, Event, Item}`. For now an alias is ensuring compatibility. - __Events__ diff --git a/composer.json b/composer.json index 808968a2..b9383c3c 100644 --- a/composer.json +++ b/composer.json @@ -59,6 +59,7 @@ "phpfastcache/dynamodb-extension": "^9.2", "phpfastcache/firestore-extension": "^9.2", "phpfastcache/mongodb-extension": "^9.2", + "phpfastcache/ravendb-extension": "^9.2", "phpfastcache/solr-extension": "^9.2" }, "autoload": { diff --git a/lib/Phpfastcache/Entities/DriverStatistic.php b/lib/Phpfastcache/Entities/DriverStatistic.php index cf2748a2..26f5b7fe 100644 --- a/lib/Phpfastcache/Entities/DriverStatistic.php +++ b/lib/Phpfastcache/Entities/DriverStatistic.php @@ -16,16 +16,25 @@ namespace Phpfastcache\Entities; +/** + * @see https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV5%CB%96%5D-The-cache-statistics + */ class DriverStatistic { protected string $info = ''; - protected int $size = 0; + protected ?int $size = 0; + + protected ?int $count = 0; protected string $data = ''; protected mixed $rawData; + /** + * Return quick information about the driver instance + * @return string + */ public function getInfo(): string { return $this->info; @@ -38,23 +47,50 @@ public function setInfo(string $info): static return $this; } - public function getSize(): int + /** + * Return the approximate size taken by the driver instance (in bytes) (null if unsupported by the driver) + * @return int|null + */ + public function getSize(): ?int { return $this->size; } - public function setSize(int $size): static + public function setSize(?int $size): static { $this->size = $size; return $this; } + /** + * Return the approximate count of elements stored in a driver database (or collection if applicable). Added in v9.2.3 + * @since 9.2.3 + * @return int|null + */ + public function getCount(): ?int + { + return $this->count; + } + + public function setCount(?int $count): static + { + $this->count = $count; + return $this; + } + + /** + * Return an array of item keys used by this driver instance (deprecated as of v9.2.3, will be removed as of v10) + * @deprecated as of phpfastcache 9.2.3, will be removed as of v10 + */ public function getData(): string { return $this->data; } + /** + * @deprecated as of phpfastcache 9.2.3, will be removed as of v10 + */ public function setData(string $data): static { $this->data = ($data ?: ''); @@ -62,6 +98,10 @@ public function setData(string $data): static return $this; } + /** + * Return a bunch of random data provided by the driver. Any type can be provided, usually an array + * @return mixed + */ public function getRawData(): mixed { return $this->rawData; @@ -82,7 +122,8 @@ public function getPublicDesc(): array return [ 'Info' => 'Cache Information', 'Size' => 'Cache Size', - 'Data' => 'Cache items keys', + 'Count' => 'Cache database/collection count', + 'Data' => 'Cache items keys (Deprecated)', 'RawData' => 'Cache raw data', ]; } diff --git a/lib/Phpfastcache/ExtensionManager.php b/lib/Phpfastcache/ExtensionManager.php index e1144475..66b5a58f 100644 --- a/lib/Phpfastcache/ExtensionManager.php +++ b/lib/Phpfastcache/ExtensionManager.php @@ -21,7 +21,7 @@ use Phpfastcache\Helper\UninstanciableObjectTrait; /** - * @internal This extension manager is meant to manager officials Phpfastcache's extensions. + * @internal This extension manager is meant to manage officials Phpfastcache's extensions. * @see \Phpfastcache\CacheManager::addCustomDriver() to add you own drivers. */ final class ExtensionManager