Skip to content

Commit cf632b7

Browse files
committed
Merge branch 'master' into 5.0
# Conflicts: # composer.json
2 parents 74ea968 + 606c28d commit cf632b7

8 files changed

+28
-53
lines changed

.travis.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ of engines available in this library that is PSR-16 compliant:
1616

1717
| Class | Description |
1818
|:---------------------------------------------------------------------------------|:--------------------------------------------------------------------|
19-
| [\ByJG\Cache\Psr16\NoCacheEngine](class-no-cache-engine.md) | Do nothing. Use it for disable the cache without change your code |
20-
| [\ByJG\Cache\Psr16\ArrayCacheEngine](class-array-cache-engine.md) | Local cache only using array. It does not persists between requests |
21-
| [\ByJG\Cache\Psr16\FileSystemCacheEngine](class-filesystem-cache-engine.md) | Save the cache result in the local file system |
22-
| [\ByJG\Cache\Psr16\MemcachedEngine](class-memcached-engine.md) | Uses the Memcached as the cache engine |
23-
| [\ByJG\Cache\Psr16\RedisCachedEngine](class-redis-cache-engine.md) | uses the Redis as cache |
24-
| [\ByJG\Cache\Psr16\SessionCachedEngine](class-session-cache-engine.md) | uses the PHP session as cache |
25-
| [\ByJG\Cache\Psr16\ShmopCachedEngine](class-shmop-cache-engine.md) | uses the shared memory area for cache |
19+
| [\ByJG\Cache\Psr16\NoCacheEngine](docs/class-no-cache-engine.md) | Do nothing. Use it for disable the cache without change your code |
20+
| [\ByJG\Cache\Psr16\ArrayCacheEngine](docs/class-array-cache-engine.md) | Local cache only using array. It does not persists between requests |
21+
| [\ByJG\Cache\Psr16\FileSystemCacheEngine](docs/class-filesystem-cache-engine.md) | Save the cache result in the local file system |
22+
| [\ByJG\Cache\Psr16\MemcachedEngine](docs/class-memcached-engine.md) | Uses the Memcached as the cache engine |
23+
| [\ByJG\Cache\Psr16\RedisCachedEngine](docs/class-redis-cache-engine.md) | uses the Redis as cache |
24+
| [\ByJG\Cache\Psr16\SessionCachedEngine](docs/class-session-cache-engine.md) | uses the PHP session as cache |
25+
| [\ByJG\Cache\Psr16\ShmopCachedEngine](docs/class-shmop-cache-engine.md) | uses the shared memory area for cache |
2626

2727
To create a new Cache Instance just create the proper cache engine and use it:
2828

@@ -41,7 +41,7 @@ if ($cache->has('key')) {
4141
$object = $cache->get('key');
4242
```
4343

44-
See more PSR-16 examples [here](basic-usage-psr16-simplecache.md)
44+
See more PSR-16 examples [here](docs/basic-usage-psr16-simplecache.md)
4545

4646
## PSR-6
4747

@@ -61,7 +61,7 @@ $cachePool = \ByJG\Cache\Factory::createFilePool();
6161
$cachePool = new CachePool(new FileSystemCacheEngine());
6262
```
6363

64-
See more PSR-6 examples [here](basic-usage-psr6-cachepool.md)
64+
See more PSR-6 examples [here](docs/basic-usage-psr6-cachepool.md)
6565

6666
## List of Available Factory Commands
6767

@@ -89,7 +89,7 @@ The Common parameters are:
8989

9090
You can add a PSR Log compatible to the constructor in order to get Log of the operations
9191

92-
See log examples [here](setup-log-handler.md)
92+
See log examples [here](docs/setup-log-handler.md)
9393

9494
## Use a PSR-11 container to retrieve the cache keys
9595

composer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,17 @@
1414
"psr/container": "^1.0|^1.1|^2.0"
1515
},
1616
"require-dev": {
17-
"phpunit/phpunit": "5.7.*|7.4.*|^9.5"
17+
"phpunit/phpunit": "^9.6",
18+
"vimeo/psalm": "^6.0"
1819
},
1920
"suggest": {
2021
"ext-memcached": "*",
2122
"ext-redis": "*",
2223
"ext-shmop": "*"
2324
},
25+
"provide": {
26+
"psr/cache-implementation": "1.0",
27+
"psr/simple-cache-implementation": "1.0"
28+
},
2429
"license": "MIT"
2530
}

docs/basic-usage-psr16-simplecache.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# Basic Usage
1+
# Basic Usage - Psr16 Simple Cache
22

3-
All implementations are PDR-16. So, just create an instance:
3+
Psr16 is a standard for cache in PHP with less verbosity than Psr6.
4+
5+
You can just instantiate the cache engine and use it as you can see below.
46

57
```php
68
<?php
@@ -19,3 +21,4 @@ if (!empty($result))
1921
}
2022
return $result;
2123
```
24+

docs/basic-usage-psr6-cachepool.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Basic Usage
1+
# Basic Usage - Psr6 Cache Pool
22

33
## Get an element from cache (using Factory...)
44

docs/class-array-cache-engine.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Class ArrayCacheEngine
22

33
This class is a simple cache engine that uses an array to store the values.
4-
It does not persists between requests.
4+
It does not persist between requests.
55

66
It is ideal to use on unit tests or when you need a simple cache engine.
77

docs/setup-log-handler.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Setup Log Handler
22

3-
This will available for the cache instances:
3+
You can add a PSR Log compatible to the constructor in order to get Log of the operations.
4+
5+
## Example
46

57
```php
68
<?php

src/Psr16/ArrayCacheEngine.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function get(string $key, mixed $default = null): mixed
6464
if ($this->has($key)) {
6565
$key = $this->getKeyFromContainer($key);
6666
$this->logger->info("[Array cache] Get '$key' from L1 Cache");
67-
return $this->cache[$key];
67+
return unserialize($this->cache[$key]);
6868
} else {
6969
$this->logger->info("[Array cache] Not found '$key'");
7070
return $default;
@@ -90,7 +90,7 @@ public function set(string $key, mixed $value, DateInterval|int|null $ttl = null
9090

9191
$this->logger->info("[Array cache] Set '$key' in L1 Cache");
9292

93-
$this->cache[$key] = $value;
93+
$this->cache[$key] = serialize($value);
9494
if (!empty($ttl)) {
9595
$this->cache["$key.ttl"] = $this->addToNow($ttl);
9696
}

0 commit comments

Comments
 (0)