Skip to content

Commit ac25502

Browse files
author
Andrey Helldar
authored
Merge pull request #3 from TheDragonCode/2.x
Package upgrade
2 parents 93e6b9a + a41a30f commit ac25502

32 files changed

+1117
-804
lines changed

.gitattributes

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
* text=auto
2+
3+
.github/ export-ignore
4+
tests/ export-ignore
5+
6+
.codecov.yml export-ignore
7+
.editorconfig export-ignore
8+
.gitattributes export-ignore
9+
.gitignore export-ignore
10+
.scrutinizer.yml export-ignore
11+
.styleci.yml export-ignore
12+
13+
phpunit.xml export-ignore

.github/workflows/phpunit.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: phpunit
2+
on: [ push ]
3+
4+
jobs:
5+
build:
6+
runs-on: ubuntu-latest
7+
8+
strategy:
9+
fail-fast: true
10+
matrix:
11+
php: [ "7.3", "7.4", "8.0" ]
12+
laravel: [ "6.0", "7.0", "8.0" ]
13+
14+
name: PHP ${{ matrix.php }}, Laravel ${{ matrix.laravel }}
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v2
19+
20+
- name: Setup Redis
21+
uses: zhulik/redis-action@1.1.0
22+
23+
- name: Setup PHP
24+
uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: ${{ matrix.php }}
27+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, redis
28+
coverage: none
29+
30+
- name: Install dependencies
31+
run: composer require --dev laravel/framework:^${{ matrix.laravel }}
32+
33+
- name: Execute tests
34+
run: sudo vendor/bin/phpunit

.gitignore

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1-
/vendor
2-
.vscode
3-
/.idea
1+
.idea/
2+
3+
build/
4+
vendor/
5+
6+
*.bak
7+
*.cache
8+
*.clover
9+
*.orig
10+
11+
*.lock

.styleci.yml

Lines changed: 65 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,67 @@
1-
preset: psr2
1+
preset: psr12
2+
3+
risky: true
24

35
enabled:
4-
- concat_without_spaces
5-
- ereg_to_preg
6-
- extra_empty_lines
7-
- short_array_syntax
8-
- method_separation
9-
- multiline_array_trailing_comma
10-
- no_empty_lines_after_phpdocs
11-
- operators_spaces
12-
- ordered_use
13-
- phpdoc_align
14-
- phpdoc_indent
15-
- phpdoc_inline_tag
16-
- phpdoc_no_access
17-
- phpdoc_no_package
18-
- phpdoc_order
19-
- phpdoc_scalar
20-
- phpdoc_separation
21-
- phpdoc_to_comment
22-
- phpdoc_trim
23-
- phpdoc_type_to_var
24-
- phpdoc_types
25-
- phpdoc_var_without_name
26-
- return
27-
- self_accessor
28-
- short_bool_cast
29-
- single_quote
30-
- spaces_after_semicolon
31-
- spaces_cast
32-
- standardize_not_equal
33-
- ternary_spaces
34-
- trim_array_spaces
35-
- unalign_double_arrow
36-
- unalign_equals
37-
- unary_operators_spaces
38-
- unneeded_control_parentheses
39-
- unused_use
40-
- whitespacy_lines
6+
- align_double_arrow
7+
- align_equals
8+
- align_phpdoc
9+
- alpha_ordered_imports
10+
- binary_operator_spaces
11+
- blank_line_before_continue
12+
- blank_line_before_declare
13+
- blank_line_before_return
14+
- blank_line_before_throw
15+
- blank_line_before_try
16+
- cast_spaces
17+
- combine_consecutive_issets
18+
- const_separation
19+
- dir_constant
20+
- fully_qualified_strict_types
21+
- logical_operators
22+
- method_separation
23+
- no_alias_functions
24+
- no_blank_lines_after_phpdoc
25+
- no_blank_lines_between_traits
26+
- no_empty_comment
27+
- no_empty_phpdoc
28+
- no_extra_block_blank_lines
29+
- no_extra_consecutive_blank_lines
30+
- no_short_bool_cast
31+
- no_trailing_comma_in_singleline_array
32+
- no_unneeded_control_parentheses
33+
- no_unused_imports
34+
- ordered_class_elements
35+
- php_unit_construct
36+
- php_unit_fqcn_annotation
37+
- phpdoc_indent
38+
- phpdoc_inline_tag
39+
- phpdoc_link_to_see
40+
- phpdoc_no_access
41+
- phpdoc_no_empty_return
42+
- phpdoc_no_package
43+
- phpdoc_no_useless_inheritdoc
44+
- phpdoc_order
45+
- phpdoc_property
46+
- phpdoc_return_self_reference
47+
- phpdoc_scalar
48+
- phpdoc_separation
49+
- phpdoc_summary
50+
- phpdoc_to_comment
51+
- phpdoc_trim
52+
- phpdoc_type_to_var
53+
- phpdoc_types
54+
- phpdoc_types_order
55+
- phpdoc_var_without_name
56+
- property_separation
57+
- self_accessor
58+
- short_array_syntax
59+
- short_list_syntax
60+
- single_line_class_definition
61+
- single_line_throw
62+
- single_quote
63+
- space_after_semicolon
64+
- standardize_not_equals
65+
- ternary_to_null_coalescing
66+
- trailing_comma_in_multiline_array
67+
- trim_array_spaces

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
The MIT License (MIT)
1+
MIT License
22

3-
Copyright (c) 2018 Andrey Helldar
3+
Copyright (c) 2021 Andrey Helldar
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 111 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,140 @@
1-
## Cache Modification helper
1+
## Laravel Cache
22

3-
### IMPORTANT!
4-
#### The package is no longer supported. To implement caching, use the [GeneaLabs/laravel-model-caching](https://github.com/GeneaLabs/laravel-model-caching) package.
5-
6-
7-
Cache helper for the [Illuminate Cache](https://github.com/illuminate/cache) package.
8-
9-
![cache](https://user-images.githubusercontent.com/10347617/40197724-f1f729be-5a1c-11e8-9854-11f1031938b7.png)
10-
11-
<p align="center">
12-
<a href="https://styleci.io/repos/119809288"><img src="https://styleci.io/repos/119809288/shield" alt="StyleCI" /></a>
13-
<a href="https://packagist.org/packages/andrey-helldar/cache"><img src="https://img.shields.io/packagist/dt/andrey-helldar/cache.svg?style=flat-square" alt="Total Downloads" /></a>
14-
<a href="https://packagist.org/packages/andrey-helldar/cache"><img src="https://poser.pugx.org/andrey-helldar/cache/v/stable?format=flat-square" alt="Latest Stable Version" /></a>
15-
<a href="https://packagist.org/packages/andrey-helldar/cache"><img src="https://poser.pugx.org/andrey-helldar/cache/v/unstable?format=flat-square" alt="Latest Unstable Version" /></a>
16-
<a href="LICENSE"><img src="https://poser.pugx.org/andrey-helldar/cache/license?format=flat-square" alt="License" /></a>
17-
</p>
3+
<img src="https://preview.dragon-code.pro/TheDragonCode/laravel-cache.svg?brand=laravel" alt="Laravel Cache"/>
184

5+
[![Stable Version][badge_stable]][link_packagist]
6+
[![Unstable Version][badge_unstable]][link_packagist]
7+
[![Total Downloads][badge_downloads]][link_packagist]
8+
[![License][badge_license]][link_license]
199

2010
## Installation
2111

22-
To get the latest version of Cache Modification, simply require the project using [Composer](https://getcomposer.org/):
12+
To get the latest version of `Laravel Cache`, simply require the project using [Composer](https://getcomposer.org):
2313

2414
```bash
25-
$ composer require andrey-helldar/cache
15+
$ composer require dragon-code/laravel-cache
2616
```
2717

28-
Instead, you may of course manually update your require block and run `composer update` if you so choose:
18+
Or manually update `require` block of `composer.json` and run `composer update`.
2919

3020
```json
3121
{
3222
"require": {
33-
"andrey-helldar/cache": "^1.0"
23+
"dragon-code/laravel-cache": "^2.0"
3424
}
3525
}
3626
```
3727

38-
Once installed, you need to register the `Helldar\Cache\ServiceProvider::class` service provider in your `config/app.php`, or if you're using Laravel 5.5, this can be done via the automatic package discovery.
28+
## Using
29+
30+
### When True
31+
32+
#### Basic
33+
34+
By default, the cache will be written for 1 day.
35+
36+
```php
37+
use DragonCode\Cache\Services\Cache;
38+
39+
$cache = Cache::make()->key('foo', 'bar', ['baz', 'baq']);
40+
41+
$cache->put(static fn() => 'Some value');
42+
// Contains cached `Some value`
43+
44+
$cache->get();
45+
// Returns cached `Some value`
46+
47+
$cache->has();
48+
// Returns `true`
49+
50+
$cache->forget();
51+
// Will remove the key from the cache.
52+
```
53+
54+
#### Custom TTL
55+
56+
The cache will be written for the specified number of minutes.
57+
58+
```php
59+
use DragonCode\Cache\Services\Cache;
60+
61+
$cache = Cache::make()
62+
->ttl($minutes)
63+
->key('foo', 'bar', ['baz', 'baq']);
64+
65+
$cache->put(static fn() => 'Some value');
66+
// Contains cached `Some value`
67+
68+
$cache->get();
69+
// Returns cached `Some value`
70+
71+
$cache->has();
72+
// Returns `true`
73+
74+
$cache->forget();
75+
// Will remove the key from the cache.
76+
```
77+
78+
#### Tagged
3979

80+
For repositories that support tagging, the keys will be saved separated by tags.
4081

41-
## How to use
82+
```php
83+
use DragonCode\Cache\Services\Cache;
84+
85+
$cache = Cache::make()
86+
->tags('actor', 'author')
87+
->key('foo', 'bar', ['baz', 'baq']);
88+
89+
$cache->put(static fn() => 'Some value');
90+
// Contains cached `Some value`
91+
92+
$cache->get();
93+
// Returns cached `Some value`
94+
95+
$cache->has();
96+
// Returns `true`
97+
98+
$cache->forget();
99+
// Will remove the key from the cache.
100+
```
101+
102+
To retrieve a tagged cache item, pass the same ordered list of tags to the tags method and then call the get method with the key you wish to retrieve:
42103

43104
```php
44-
return cache_mod()
45-
->key('it', 'is', 'a', 'key')
46-
->minutes(60)
47-
->tags('it', 'is', 'a', 'tags')
48-
->remember(function() {
49-
return 'my value';
50-
});
51-
52-
return cache_mod()
53-
->key('it', 'is', 'a', 'key')
54-
->remember(function() {
55-
return 'my value';
56-
});
105+
use DragonCode\Cache\Services\Cache;
106+
107+
$cache = Cache::make()
108+
->key('foo', 'bar');
109+
110+
$cache->tags('actor', 'author')->put(static fn() => 'Some value');
111+
// Contains cached `Some value`
112+
113+
$cache->tags('actor', 'author')->get();
114+
// Returns cached `Some value`
115+
116+
$cache->tags('actor')->get();
117+
// Returns `null`
118+
119+
$cache->tags('author')->get();
120+
// Returns `null`
57121
```
58122

59-
To disable the caching, you need to set the `CACHE_DRIVER=array` in `.env`.
123+
> See the official Laravel [documentation](https://laravel.com/docs/cache#accessing-tagged-cache-items).
124+
125+
## License
126+
127+
This package's licensed under the [MIT License](LICENSE).
128+
60129

130+
[badge_downloads]: https://img.shields.io/packagist/dt/dragon-code/laravel-cache.svg?style=flat-square
61131

62-
## Copyright and License
132+
[badge_license]: https://img.shields.io/packagist/l/dragon-code/laravel-cache.svg?style=flat-square
63133

64-
Cache Modification for [Illuminate Cache](https://github.com/illuminate/cache) package was written by Andrey Helldar for the Laravel framework 5.4 or above, and is released under the MIT License. See the [LICENSE](LICENSE) file for details.
134+
[badge_stable]: https://img.shields.io/github/v/release/dragon-code/laravel-cache?label=stable&style=flat-square
65135

136+
[badge_unstable]: https://img.shields.io/badge/unstable-dev--main-orange?style=flat-square
66137

67-
## Translation
138+
[link_license]: LICENSE
68139

69-
Translations of text and comment by Google Translate. Help with translation +1 in karma :)
140+
[link_packagist]: https://packagist.org/packages/dragon-code/laravel-cache

0 commit comments

Comments
 (0)