Skip to content

Commit

Permalink
Started 9.2 (WIP):
Browse files Browse the repository at this point in the history
- __API__
  - Upgraded Phpfastcache API to `4.3.0` ([see changes](CHANGELOG_API.md))
- __Drivers__
  - Implemented #906 // **Added `RedisCluster` driver support**
- __Pool__
  - Added `ExtendedCacheItemPoolTrait::getAllItems` to allow you to retrieve all items in the cache. This method have some limitations, ([see more in the Wiki](https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV5%CB%96%5D-Fetching-all-keys)).
- __Core__
  - Configuration methods`ConfigurationOption::isPreventCacheSlams()`, `ConfigurationOption::setPreventCacheSlams()`, `ConfigurationOption::getCacheSlamsTimeout()`, `ConfigurationOption::setCacheSlamsTimeout()` are deprecated. ([See changes](CHANGELOG_API.md)).
  - Fixed #907 // Internal "driver decode()" method will now throw an if the string data looks corrupted.
  - Internal: Implemented multiple keys fetch (*if supported by the backend*) to improve the performances behind all `getItems()` calls. Currently only supported in some backends, but it may evolve in the future.
- __Misc__
  - Fixed multiple code typo & updated README.md
  • Loading branch information
Geolim4 committed Dec 15, 2023
1 parent c82647a commit 03d05da
Show file tree
Hide file tree
Showing 62 changed files with 1,440 additions and 267 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
## 9.2.0
##### xx january 2024
- __API__
- Upgraded Phpfastcache API to `4.3.0` ([see changes](CHANGELOG_API.md))
- __Drivers__
- Implemented #906 // **Added `RedisCluster` driver support**
- __Pool__
- Added `ExtendedCacheItemPoolTrait::getAllItems` to allow you to retrieve all items in the cache. This method have some limitations, ([see more in the Wiki](https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV5%CB%96%5D-Fetching-all-keys)).
- __Core__
- Configuration methods`ConfigurationOption::isPreventCacheSlams()`, `ConfigurationOption::setPreventCacheSlams()`, `ConfigurationOption::getCacheSlamsTimeout()`, `ConfigurationOption::setCacheSlamsTimeout()` are deprecated. ([See changes](CHANGELOG_API.md)).
- Fixed #907 // Internal "driver decode()" method will now throw an if the string data looks corrupted.
- Internal: Implemented multiple keys fetch (*if supported by the backend*) to improve the performances behind all `getItems()` calls. Currently only supported in some backends, but it may evolve in the future.
- __Misc__
- Fixed multiple code typo & updated README.md

## 9.1.3
##### 12 february 2023
- __Core__
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG_API.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## 4.3.0
- Created method `ExtendedCacheItemPoolTrait::getAllItems(string $pattern = ''): iterable` which will return all the items stored in the cache. This method have some limitations, ([see more in the Wiki](https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV5%CB%96%5D-Fetching-all-keys)).
- Deprecated `ConfigurationOption::isPreventCacheSlams()` for future removal, use `IOConfigurationOption::isPreventCacheSlams()` instead.
- Deprecated `ConfigurationOption::setPreventCacheSlams()` for future removal, use `IOConfigurationOption::setPreventCacheSlams()` instead.
- Deprecated `ConfigurationOption::getCacheSlamsTimeout()` for future removal, use `IOConfigurationOption::getCacheSlamsTimeout()` instead.
- Deprecated `ConfigurationOption::setCacheSlamsTimeout()` for future removal, use `IOConfigurationOption::setCacheSlamsTimeout()` instead.
- Created `IOConfigurationOption::isPreventCacheSlams()`. This method will **only be available** for `Files, Sqlite, Leveldb` drivers.
- Created `IOConfigurationOption::setPreventCacheSlams()`. This method will **only be available** for `Files, Sqlite, Leveldb` drivers.
- Created `IOConfigurationOption::getCacheSlamsTimeout()`. This method will **only be available** for `Files, Sqlite, Leveldb` drivers.
- Created `IOConfigurationOption::setCacheSlamsTimeout()`. This method will **only be available** for `Files, Sqlite, Leveldb` drivers.


## 4.2.0
- Created method `\Phpfastcache\Cluster\AggregatablePoolInterface::isAggregatedBy(): ?ClusterPoolInterface` which will return the aggregator object for Cluster aggregators
- Created method `\Phpfastcache\Cluster\AggregatablePoolInterface::setAggregatedBy(ClusterPoolInterface $clusterPool): static` which will allow to set the aggregator object
Expand Down
84 changes: 42 additions & 42 deletions README.md

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@
"psr/cache": "^2.0||^3.0",
"psr/simple-cache": "^2.0||^3.0",
"ext-mbstring": "*",
"ext-json": "*"
"ext-json": "*",
"symfony/var-dumper": "^6.0",
"doctrine/couchdb": "dev-master",
"phpfastcache/phpssdb": "~1.1",
"predis/predis": "~1.1",
"mongodb/mongodb": "~1.9",
"triagens/arangodb": "~3.8",
"aws/aws-sdk-php": "~3.2",
"google/cloud-firestore": "~1.20",
"solarium/solarium": "~6.1"
},
"require-dev": {
"league/climate": "^3.8",
Expand Down
3 changes: 2 additions & 1 deletion docs/DRIVERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@
* A very high-performance NoSQL driver using a key-value pair system.
* Predis
* A high-performance memory driver using a in-memory data structure storage. Less efficient than Redis driver as it is an embedded library.
* Redis
* Redis/RedisCluster
* A very high-performance memory driver using a in-memory data structure storage. More efficient than Predis driver as it is an compiled library.
* RedisCluster use the RedisCluster class with a different driver name but behave slightly differently than Redis driver.
* Riak **(REMOVED in v8.0.6)**
* A very high-performance NoSQL driver using a key-value pair system.
* Solr **(Added in V9.1)**
Expand Down
14 changes: 13 additions & 1 deletion docs/EVENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,19 @@ This is an exhaustive list, and it will be updated as soon as new events will be
- *ExtendedCacheItemPoolInterface::getItems()*
- *ExtendedCacheItemPoolInterface::getItemsByTag()*
- *ExtendedCacheItemPoolInterface::getItemsAsJsonString()*

- onCacheGetItems(*Callable* **$callback**)
- **Callback arguments**
- *ExtendedCacheItemPoolInterface* **$itemPool**
- *ExtendedCacheItemInterface[]* **$items**
- **Scope**
- ItemPool
- **Description**
- Allow you to manipulate a set of items just before it gets returned by the getItems() method.
- **Risky Circular Methods**
- *ExtendedCacheItemPoolInterface::getItem()*
- *ExtendedCacheItemPoolInterface::getItems()*
- *ExtendedCacheItemPoolInterface::getItemsByTag()*
- *ExtendedCacheItemPoolInterface::getItemsAsJsonString()*
- onCacheDeleteItem(*Callable* **$callback**)
- **Callback arguments**
- *ExtendedCacheItemPoolInterface* **$itemPool**
Expand Down
2 changes: 1 addition & 1 deletion lib/Phpfastcache/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Api
{
use UninstanciableObjectTrait;

protected static string $version = '4.2.0';
protected static string $version = '4.3.0';

/**
* This method will return the current
Expand Down
17 changes: 17 additions & 0 deletions lib/Phpfastcache/Config/ConfigurationOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ public function setPath(string $path): static
}

/**
* @deprecated This method is deprecated and will be soon moved to IOConfigurationOption class, which means they will only be available for `IO` drivers.
* @return bool
*/
public function isPreventCacheSlams(): bool
Expand All @@ -240,18 +241,27 @@ public function isPreventCacheSlams(): bool
}

/**
* @deprecated This method is deprecated and will be soon moved to IOConfigurationOption class, which means they will only be available for `IO` drivers.
* @param bool $preventCacheSlams
* @return ConfigurationOption
* @throws PhpfastcacheLogicException
*/
public function setPreventCacheSlams(bool $preventCacheSlams): static
{
if ($preventCacheSlams !== $this->preventCacheSlams) {
trigger_error(
'This method is deprecated and will be soon moved to IOConfigurationOption class, which means they will only be available for `IO` drivers.',
E_USER_DEPRECATED
);
}

$this->enforceLockedProperty(__FUNCTION__);
$this->preventCacheSlams = $preventCacheSlams;
return $this;
}

/**
* @deprecated This method is deprecated and will be soon moved to IOConfigurationOption class, which means they will only be available for `IO` drivers.
* @return int
*/
public function getCacheSlamsTimeout(): int
Expand All @@ -260,12 +270,19 @@ public function getCacheSlamsTimeout(): int
}

/**
* @deprecated This method is deprecated and will be soon moved to IOConfigurationOption class, which means they will only be available for `IO` drivers.
* @param int $cacheSlamsTimeout
* @return ConfigurationOption
* @throws PhpfastcacheLogicException
*/
public function setCacheSlamsTimeout(int $cacheSlamsTimeout): static
{
if ($cacheSlamsTimeout !== $this->cacheSlamsTimeout) {
trigger_error(
'This method is deprecated and will be soon moved to IOConfigurationOption class, which means they will only be available for `IO` drivers.',
E_USER_DEPRECATED
);
}
$this->enforceLockedProperty(__FUNCTION__);
$this->cacheSlamsTimeout = $cacheSlamsTimeout;
return $this;
Expand Down
21 changes: 0 additions & 21 deletions lib/Phpfastcache/Config/ConfigurationOptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,27 +106,6 @@ public function getPath(): string;
*/
public function setPath(string $path): static;

/**
* @return bool
*/
public function isPreventCacheSlams(): bool;

/**
* @param bool $preventCacheSlams
* @return ConfigurationOption
*/
public function setPreventCacheSlams(bool $preventCacheSlams): static;

/**
* @return int
*/
public function getCacheSlamsTimeout(): int;

/**
* @param int $cacheSlamsTimeout
* @return ConfigurationOption
*/
public function setCacheSlamsTimeout(int $cacheSlamsTimeout): static;
/**
* @return bool
*/
Expand Down
48 changes: 46 additions & 2 deletions lib/Phpfastcache/Config/IOConfigurationOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
use Phpfastcache\Exceptions\PhpfastcacheInvalidConfigurationException;
use Phpfastcache\Exceptions\PhpfastcacheLogicException;

/**
* @todo: As of V10, imports cache slams properties.
*/
class IOConfigurationOption extends ConfigurationOption
{
protected bool $secureFileManipulation = false;
Expand Down Expand Up @@ -60,7 +63,7 @@ public function isSecureFileManipulation(): bool

/**
* @param bool $secureFileManipulation
* @return self
* @return static
* @throws PhpfastcacheLogicException
*/
public function setSecureFileManipulation(bool $secureFileManipulation): static
Expand Down Expand Up @@ -113,7 +116,7 @@ public function getDefaultChmod(): int

/**
* @param int $defaultChmod
* @return self
* @return static
* @throws PhpfastcacheLogicException
*/
public function setDefaultChmod(int $defaultChmod): static
Expand All @@ -122,4 +125,45 @@ public function setDefaultChmod(int $defaultChmod): static
$this->defaultChmod = $defaultChmod;
return $this;
}


/**
* @return bool
*/
public function isPreventCacheSlams(): bool
{
return $this->preventCacheSlams;
}

/**
* @param bool $preventCacheSlams
* @return static
* @throws PhpfastcacheLogicException
*/
public function setPreventCacheSlams(bool $preventCacheSlams): static
{
$this->enforceLockedProperty(__FUNCTION__);
$this->preventCacheSlams = $preventCacheSlams;
return $this;
}

/**
* @return int
*/
public function getCacheSlamsTimeout(): int
{
return $this->cacheSlamsTimeout;
}

/**
* @param int $cacheSlamsTimeout
* @return static
* @throws PhpfastcacheLogicException
*/
public function setCacheSlamsTimeout(int $cacheSlamsTimeout): static
{
$this->enforceLockedProperty(__FUNCTION__);
$this->cacheSlamsTimeout = $cacheSlamsTimeout;
return $this;
}
}
8 changes: 8 additions & 0 deletions lib/Phpfastcache/Config/IOConfigurationOptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,12 @@ public function setCacheFileExtension(string $cacheFileExtension): static;
public function getDefaultChmod(): int;

public function setDefaultChmod(int $defaultChmod): static;

public function isPreventCacheSlams(): bool;

public function setPreventCacheSlams(bool $preventCacheSlams): static;

public function getCacheSlamsTimeout(): int;

public function setCacheSlamsTimeout(int $cacheSlamsTimeout): static;
}
7 changes: 4 additions & 3 deletions lib/Phpfastcache/Core/Item/ExtendedCacheItemInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ interface ExtendedCacheItemInterface extends
public function getEncodedKey(): string;

/**
* Returns the raw value, regardless of hit status.
* Returns the cache item value, regardless of hit status.
* This method can be called if the cache item is NOT YET
* persisted, and you need to access to its set value.
*
Expand All @@ -53,9 +53,10 @@ public function getEncodedKey(): string;
*
* @return mixed
*
* @internal
* @internal This method is used internally by phpfastcache, so you should not use it in your application.
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
*/
public function getRawValue(): mixed;
public function _getData(): mixed; // @phpcs:ignore

/**
* @return DateTimeInterface
Expand Down
5 changes: 3 additions & 2 deletions lib/Phpfastcache/Core/Item/ExtendedCacheItemTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ public function getEncodedKey(): string

/**
* @inheritDoc
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
*/
public function getRawValue(): mixed
public function _getData(): mixed // @phpcs:ignore
{
return $this->data;
}
Expand Down Expand Up @@ -281,7 +282,7 @@ public function prepend(array|string $data): ExtendedCacheItemInterface

/**
* Return the data as a well-formatted string.
* Any scalar value will be casted to an array
* Any scalar value will be cast to an array
* @param int $options \json_encode() options
* @param int $depth \json_encode() depth
* @return string
Expand Down
2 changes: 1 addition & 1 deletion lib/Phpfastcache/Core/Item/TaggableCacheItemTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function getRemovedTags(): array
public function cloneInto(ExtendedCacheItemInterface $itemTarget, ?ExtendedCacheItemPoolInterface $itemPoolTarget = null): void
{
$itemTarget->setEventManager($this->getEventManager())
->set($this->getRawValue())
->set($this->_getData())
->setHit($this->isHit())
->setTags($this->getTags())
->expiresAt(clone $this->getExpirationDate())
Expand Down
Loading

0 comments on commit 03d05da

Please sign in to comment.