Skip to content

Commit

Permalink
Updated of DriverStatistic. After almost 8 years untouched 馃榿
Browse files Browse the repository at this point in the history
  • Loading branch information
Geolim4 committed Jan 13, 2024
1 parent 1e605b0 commit 372d62e
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 6 deletions.
11 changes: 10 additions & 1 deletion 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__
Expand All @@ -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__
Expand Down
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -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": {
Expand Down
49 changes: 45 additions & 4 deletions lib/Phpfastcache/Entities/DriverStatistic.php
Expand Up @@ -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;
Expand All @@ -38,30 +47,61 @@ 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 ?: '');

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;
Expand All @@ -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',
];
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Phpfastcache/ExtensionManager.php
Expand Up @@ -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
Expand Down

0 comments on commit 372d62e

Please sign in to comment.