File tree 6 files changed +24
-21
lines changed
6 files changed +24
-21
lines changed Original file line number Diff line number Diff line change 26
26
"escapestudios/symfony2-coding-standard" : " ^3.0" ,
27
27
"slevomat/coding-standard" : " ^4.0" ,
28
28
"friendsofphp/php-cs-fixer" : " ^2.3" ,
29
- "monolog/monolog" : " ^1.23"
29
+ "monolog/monolog" : " ^1.23" ,
30
+ "psr/simple-cache" : " ^1.0"
30
31
},
31
32
"autoload" : {
32
33
"psr-4" : {
Original file line number Diff line number Diff line change 2
2
3
3
namespace Rentberry \MapsUtils \Cache ;
4
4
5
+ use Psr \SimpleCache \CacheInterface ;
6
+
5
7
/**
6
8
* Cache service
7
9
*/
8
10
class Cache
9
11
{
10
12
/**
11
- * @var \Memcached
13
+ * @var CacheInterface
12
14
*/
13
15
protected $ cache ;
14
16
15
17
/**
16
- * @param \Memcached $cache
18
+ * @param CacheInterface $cache
17
19
*/
18
- public function __construct (\ Memcached $ cache )
20
+ public function __construct (CacheInterface $ cache )
19
21
{
20
22
$ this ->cache = $ cache ;
21
23
}
22
24
23
25
/**
24
- * @param CacheInterface $object
26
+ * @param CacheableInterface $object
25
27
*
26
28
* @return false|mixed
27
29
*/
28
- public function getData (CacheInterface $ object )
30
+ public function getData (CacheableInterface $ object )
29
31
{
30
32
$ cacheKey = $ object ->getCacheKey ();
31
- $ data = $ this ->cache ->get ($ cacheKey );
33
+ $ data = $ this ->cache ->get ($ cacheKey, null );
32
34
33
- if ($ data !== false ) {
35
+ if ($ data !== null ) {
34
36
return $ data ;
35
37
}
36
38
@@ -46,11 +48,11 @@ public function getData(CacheInterface $object)
46
48
/**
47
49
* Force update data in cache
48
50
*
49
- * @param CacheInterface $object
51
+ * @param CacheableInterface $object
50
52
*
51
53
* @return false|mixed
52
54
*/
53
- public function updateData (CacheInterface $ object )
55
+ public function updateData (CacheableInterface $ object )
54
56
{
55
57
$ cacheKey = $ object ->getCacheKey ();
56
58
$ data = $ object ->getData ();
Original file line number Diff line number Diff line change 3
3
namespace Rentberry \MapsUtils \Cache ;
4
4
5
5
/**
6
- * Interface Cache
6
+ * Interface Cacheable
7
7
*/
8
- interface CacheInterface
8
+ interface CacheableInterface
9
9
{
10
10
/**
11
11
* @return mixed
Original file line number Diff line number Diff line change 5
5
/**
6
6
* Cache object
7
7
*/
8
- class CacheObject implements CacheInterface
8
+ class CacheableObject implements CacheableInterface
9
9
{
10
10
/**
11
11
* @var string
@@ -36,9 +36,9 @@ public function getData()
36
36
/**
37
37
* @param string $cacheKey
38
38
*
39
- * @return CacheObject
39
+ * @return CacheableObject
40
40
*/
41
- public function setCacheKey (string $ cacheKey ): CacheObject
41
+ public function setCacheKey (string $ cacheKey ): CacheableObject
42
42
{
43
43
$ this ->cacheKey = $ cacheKey ;
44
44
@@ -48,9 +48,9 @@ public function setCacheKey(string $cacheKey): CacheObject
48
48
/**
49
49
* @param mixed $data
50
50
*
51
- * @return CacheObject
51
+ * @return CacheableObject
52
52
*/
53
- public function setData ($ data ): CacheObject
53
+ public function setData ($ data ): CacheableObject
54
54
{
55
55
$ this ->data = $ data ;
56
56
Original file line number Diff line number Diff line change 5
5
use GuzzleHttp \Client ;
6
6
use Psr \Log \LoggerInterface ;
7
7
use Rentberry \MapsUtils \Cache \Cache ;
8
- use Rentberry \MapsUtils \Cache \CacheInterface ;
8
+ use Rentberry \MapsUtils \Cache \CacheableInterface ;
9
9
use Rentberry \MapsUtils \Objects \Place ;
10
10
11
11
/**
12
12
* MapsPlace
13
13
*/
14
- class MapsPlace implements CacheInterface
14
+ class MapsPlace implements CacheableInterface
15
15
{
16
16
public const QUERY_TYPE_ADDRESS = 'address ' ;
17
17
public const QUERY_TYPE_PLACE_ID = 'place_id ' ;
Original file line number Diff line number Diff line change 5
5
use GuzzleHttp \Client ;
6
6
use Psr \Log \LoggerInterface ;
7
7
use Rentberry \MapsUtils \Cache \Cache ;
8
- use Rentberry \MapsUtils \Cache \CacheInterface ;
8
+ use Rentberry \MapsUtils \Cache \CacheableInterface ;
9
9
10
10
/**
11
11
* MapsTimezone
12
12
*/
13
- class MapsTimezone implements CacheInterface
13
+ class MapsTimezone implements CacheableInterface
14
14
{
15
15
private const LOCATION_ROUND_LEVEL = 3 ;
16
16
/**
You can’t perform that action at this time.
0 commit comments