terah / redis-cache
A very simple redis caching lib with hierarchical keys
6.0.0.9
2021-01-18 12:38 UTC
Requires
- php: >=7.4
- ext-redis: *
- psr/log: 1.*
- terah/fluent-assert: 6.*
Requires (Dev)
- scrutinizer/ocular: ~1.1
- dev-master
- 6.0.0.9
- 6.0.0.8
- 6.0.0.7
- 6.0.0.5
- 6.0.0.0
- 5.0.0.7
- 5.0.0.6
- 5.0.0.5
- 5.0.0.3
- 5.0.0.1
- 4.0.7.3
- 4.0.6.7
- 4.0.6.5
- 4.0.6.4
- 4.0.6.3
- 4.0.6.2
- 4.0.5.51
- 4.0.5.40
- 4.0.5.39
- 4.0.5.38
- 4.0.5.37
- 4.0.5.36
- 4.0.5.35
- 4.0.5.33
- 4.0.5.31
- 4.0.5.26
- 4.0.5.23
- 4.0.5.22
- 4.0.5.18
- 4.0.5.17
- 4.0.5.15
- 4.0.5.14
- 4.0.5.13
- 4.0.5.12
- 4.0.5.11
- 4.0.5.10
- 4.0.5.9
- 4.0.5.8
- 4.0.5.7
- 4.0.5.6
- 4.0.5.5
- 4.0.5.4
- 4.0.5.3
- 4.0.5.2
- 4.0.5.1
- 4.0.5.0
- 4.0.4.9
- 4.0.4.7
- 4.0.4.5
- 4.0.4.4
- 4.0.4.3
- 4.0.4.2
- 4.0.4.1
- 4.0.4.0
- 4.0.3.9
- 4.0.3.8
- 4.0.3.7
- 4.0.3.6
- 4.0.3.5
- 4.0.3.4
- 4.0.3.3
- 4.0.3.2
- 4.0.3.1
- 4.0.2.7
- 4.0.2.6
- 4.0.2.4
- 4.0.2.3
- 4.0.2.2
- 4.0.2.1
- 4.0.2.0
- 4.0.1.9
- 4.0.1.8
- 4.0.1.7
- 4.0.1.6
- 4.0.1.5
- 4.0.1.4
- 4.0.1.3
- 4.0.1.2
- 4.0.1.0
- 4.0.0.6
- 4.0.0.5
- 4.0.0.2
- 3.0.0.3
- 3.0.0.2
- 3.0.0.1
- 3.0.0.0
- 2.0.0.4
- 2.0.0.2
- 2.0.0.1
- 2.0.0.0
- 1.0.5.3
- 1.0.5.2
- 1.0.5.1
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
This package is auto-updated.
Last update: 2024-12-18 20:52:50 UTC
README
Super simple redis caching implementation.
Install
Via Composer
$ composer require terah/redis-cache
Usage
$redis = new \Redis();
$redis->connect('127.0.0.1', 6379);
$namespace = 'my-short-db-cache';
$defaultTtl = 60 * 60; // 1 hour
$cache = new Terah\RedisCache\RedisCache($redis, $defaultTtl, $namespace);
// Save your data
$cache->set('my-user-list', expensiveFunctionCall(), 60 * 60 * 2); // Ttl will default to $defaultTtl
// Fetch your data
$myData = $cache->get('my-user-list');
// Deletes
$cache->delete('my-user-list');
// Convenient callback handler
$callback = function() {
return expensiveDataFetch();
}
$data = $cache->remember('my-user-list', $callback, 60 * 60 * 1);
// Hierarchical keys - caching in 'directories'
$cache->set('/user_data/user_profiles/freddy', $data);
$cache->set('/user_data/user_profiles/betty', $data);
$cache->set('/user_data/user_profiles/micky', $data);
// now you can flush all user data:
$cache->delete('/user_data/');
Change log
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Security
If you discover any security related issues, please email terry@terah.com.au instead of using the issue tracker.
Credits
- [Terry Cullen][https://bitbucket.org/terahdigital]
- All Contributors
License
The MIT License (MIT). Please see License File for more information.