From da951c468c7efd78283bb2b1513cf8f80352e5b2 Mon Sep 17 00:00:00 2001 From: Carlos Matos <118901076+cmatosbc@users.noreply.github.com> Date: Mon, 4 Nov 2024 20:00:10 +0000 Subject: [PATCH] Update README.md --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 72a1311..0c6f651 100644 --- a/README.md +++ b/README.md @@ -80,3 +80,15 @@ $result = $cachedStaticMethod([MyClass::class, 'staticMethod'], 'arg1', 'arg2'); * Reducing Server Load: Offload processing to the cache, especially for computationally expensive tasks. By using these functions, you can significantly improve the performance of your WordPress applications. + +## JS like syntax: + +A JS like syntax can also be used with PHP closures, so the next arguments can be passed directly to the Closure, like this. + +```php +// Cache a custom function for 5 minutes +$expireTime = new DateTime('+5 minutes'); +$result = withCache($cache, $expireTime)(function () { + return 'Hello, world!'; +}); +```