Skip to content

Commit d844b55

Browse files
authored
Merge pull request #1 from byjg/3.0.0
3.0.0
2 parents eff5714 + ec34b0b commit d844b55

21 files changed

+755
-629
lines changed

.travis.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
language: php
2+
3+
services:
4+
- memcached
5+
- redis-server
6+
7+
addons:
8+
hosts:
9+
- memcached-container
10+
- redis-container
11+
12+
php:
13+
- "7.0"
14+
- "5.6"
15+
16+
install:
17+
- composer install
18+
19+
script:
20+
- phpunit --stderr

README.md

Lines changed: 29 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Cache Engine
2+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/byjg/cache-engine-php/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/byjg/cache-engine-php/?branch=master)
23
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/f643fd22-8ab1-4f41-9bef-f9f9e127ec0d/mini.png)](https://insight.sensiolabs.com/projects/f643fd22-8ab1-4f41-9bef-f9f9e127ec0d)
4+
[![Build Status](https://travis-ci.org/byjg/cache-engine-php.svg?branch=master)](https://travis-ci.org/byjg/cache-engine-php)
5+
36

47
## Description
58

@@ -18,12 +21,12 @@ A multi-purpose cache engine in PHP with several drivers. PSR-6 compliant.
1821

1922
## Create new cache instance
2023

21-
### Creating a PSR-6 compatible instance (RECOMMENDED)
24+
### Creating a PSR-6 compatible instance
2225

2326
You can set instance in the 'cacheconfig.php' setup (see below how to configure the factory)
2427

2528
```php
26-
$cachePool = \ByJG\Cache\CacheContext::psrFactory();
29+
$cachePool = \ByJG\Cache\Factory::createFilePool();
2730
```
2831

2932
or you can create the CachePool imediatelly:
@@ -32,101 +35,45 @@ or you can create the CachePool imediatelly:
3235
$cachePool = new CachePool(new FileSystemCacheEngine());
3336
```
3437

38+
### Logging cache commands
39+
40+
You can add a PSR Log compatible to the constructor in order to get Log of the operations
3541

36-
### Use the cache engine instance
3742

38-
You can create a instance from the Cache engine directly. This is not PSR-6 compliant, but implements
39-
features that the CachePool does not support and it is for backward compatibilty also.
43+
### List of Avaiable Factory Commands
4044

41-
You can create from the factory and cacheconfig.php file:
45+
**Note: All parameters are optional**
4246

43-
```php
44-
$cacheEngine = \ByJG\Cache\CacheContext::factory();
45-
```
47+
| Engine | Factory Command |
48+
|:-----------------|:----------------------------------------------------------------------|
49+
| No Cache | Factory::createNullPool($prefix, $bufferSize, $logger); |
50+
| Array | Factory::createArrayPool($bufferSize, $logger); |
51+
| File System | Factory::createFilePool($prefix, $bufferSize, $logger); |
52+
| Memcached | Factory::createMemcachedPool($servers[], $bufferSize, $logger); |
53+
| Session | Factory::createSessionPool($prefix, $bufferSize, $logger); |
54+
| Redis | Factory::createRedisCacheEngine($server, $pwd, $bufferSize, $logger); |
55+
| Shmop | Factory::createShmopPool($config[], $bufferSize, $logger); |
4656

47-
or instantiate directly
57+
The Commom parameters are:
4858

49-
```php
50-
$cacheEngine = new \ByJG\Cache\MemcachedEngine();
51-
```
59+
- logger: A valid instance that implement the LoggerInterface defined by the PSR/LOG
60+
- bufferSize: the Buffer of CachePool
61+
- prefix: A prefix name to compose the KEY physically
62+
- servers: An array of memcached servers. E.g.: `[ '127.0.0.1:11211' ]`
63+
- config: Specific setup for shmop. E.g.: `[ 'max-size' => 524288, 'default-permission' => '0700' ]`
5264

5365
## Install
5466

55-
Just type: `composer require "byjg/cache-engine=2.0.*"`
56-
57-
## Setup the Factory Config
58-
59-
You need to have a file named `config/cacheconfig.php` with the follow contents:
60-
61-
### Basic Configuration
62-
63-
```php
64-
return [
65-
'default' => [
66-
'instance' => '\\ByJG\\Cache\\NoCacheEngine'
67-
]
68-
];
69-
```
70-
71-
The parameters are described below:
72-
73-
* 'default' is the name of the key used in the CacheContext::factory(key)
74-
* 'instance' is required if you use CacheContext::factory. Must have the full name space for the cache class;
75-
76-
### Setting the Cache Pool Buffer
67+
Just type: `composer require "byjg/cache-engine=3.0.*"`
7768

78-
CachePool implementation have a local buffer saving some elements locally for speedup the access.
79-
If you set to '0' the pool buffer will be disabled.
8069

81-
```php
82-
return [
83-
'default' => [
84-
'instance' => '\\ByJG\\Cache\\MemcachedEngine',
85-
'poolbuffer' => 10
86-
]
87-
];
88-
```
89-
90-
91-
### Specific configuration for Memcached
70+
## Running Unit Testes
9271

93-
```php
94-
return [
95-
'default' => [
96-
'instance' => '\\ByJG\\Cache\\MemcachedEngine',
97-
'memcached' => [
98-
'servers' => [
99-
'127.0.0.1:11211'
100-
]
101-
],
102-
]
103-
];
10472
```
105-
106-
The parameters are described below:
107-
108-
* 'memcached' have specific configuration for the MemcachedEngine class.
109-
110-
### Specific configuration for Shmop Cache
111-
112-
```php
113-
return [
114-
'default' => [
115-
'instance' => '\\ByJG\\Cache\\ShmopCacheEngine',
116-
'shmop' => [
117-
'max-size' => 1048576,
118-
'default-permission' => '0700'
119-
]
120-
]
121-
];
73+
phpunit --stderr
12274
```
12375

124-
The parameters are described below:
125-
126-
* 'shmop' have specific configuration for the ShmopCacheEngine class.
127-
128-
129-
76+
**Note:** the parameter `--stderr` after `phpunit` is to permit run the tests on SessionCacheEngine.
13077

13178
----
13279
[Open source ByJG](http://opensource.byjg.com)

composer.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
},
1515
"require": {
1616
"php": ">=5.4.0",
17-
"monolog/monolog": "1.*",
18-
"byjg/singleton-pattern": "1.0.*",
19-
"sheikhheera/iconfig": "1.0.*",
20-
"psr/cache": "1.0.*"
17+
"psr/cache": "1.0.*",
18+
"psr/log": "1.0.2"
2119
},
2220
"suggest": {
2321
"ext-memcached": "*"

config/cacheconfig-dist.php

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

nbproject/project.properties

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

nbproject/project.xml

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

phpunit.xml.dist

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
To change this license header, choose License Headers in Project Properties.
4+
To change this template file, choose Tools | Templates
5+
and open the template in the editor.
6+
-->
7+
8+
<!-- see http://www.phpunit.de/wiki/Documentation -->
9+
<phpunit bootstrap="./vendor/autoload.php"
10+
colors="false"
11+
convertErrorsToExceptions="true"
12+
convertNoticesToExceptions="true"
13+
convertWarningsToExceptions="true"
14+
stopOnFailure="false">
15+
16+
<filter>
17+
<whitelist>
18+
<directory>./src</directory>
19+
</whitelist>
20+
</filter>
21+
22+
<testsuites>
23+
<testsuite name="Test Suite">
24+
<directory>./tests/</directory>
25+
</testsuite>
26+
</testsuites>
27+
28+
</phpunit>

src/CacheContext.php

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

0 commit comments

Comments
 (0)