Download the PHP package hi-man/localcache without Composer
On this page you can find all versions of the php package hi-man/localcache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hi-man/localcache
More information about hi-man/localcache
Files in hi-man/localcache
Package localcache
Short Description provides a cache with local and remote cache
License MIT
Informations about the package localcache
LocalCache
now, let's back to our classroom,
professor is talking about the architecture of cpu
,
just like the software your are creating,Redis
is the L2
cache,
and Yac
is the L1
cache for your software,
and LocalCache
is the cache manager of Redis
and Yac
.
so, if your redis server is busying, and your data does not change frequently,
LocalCache
is the right man you are finding.
If I have seen further, it is by standing on the shoulders of giants.
- Feature
- Usage
- Requirement
- Install
- testing
- Classes
- CachePoolService
- initCacheInstance
- getCacheInstance
- setCacheValue
- getCacheValue
- deleteByKey
- CacheService
- getConfigByConnection
- logException
- setCacheValue
- getCacheValue
- deleteByKey
- LocalCache
- Construct
- select
- get
- set
- delete / unlink
- expire
- clear
- hDel / hGetAll / hMSet / hMGet / hSet / hGet
- setLocalCacheTimeout
- getLocalCacheTimeout
Feature
- [x] a redis client with retry mechanism
- [x] reduce redis requests by caching data in memory
- [x] support redis connection pool
- [x] more graceful exception handler
- [x] disable cache on demands
Usage
- extend class
CacheService
(recommend) - use static funcitons in
CachePoolService
- use
LocalCache
class directly
Requirement
- PHP 7.0+
- phpredis
- yac
Install
testing
Classes
CachePoolService
pool of LocalCache
, can be called statically
initCacheInstance
initialize LocalCache
getCacheInstance
get instance of LocalCache
by connection name
setCacheValue
set cache value
getCacheValue
get cache value
deleteByKey
delete from cache by key
CacheService
abstract class to use CachePoolService more productive
getConfigByConnection
MUST implemented get redis configuration by connection identifier
logException
MUST implemented exception handler
setCacheValue
wrapper of CachePoolService::setCacheValue
getCacheValue
wrapper of CachePoolService::getCacheValue
deleteByKey
wrapper of CachePoolService::deleteByKey
LocalCache
provide a local cache between application and redis server
Construct
select
the same as redis command select
, but not really issue a command request.
get
the same as redis command get
, use yac cache value first, then issue a command request if cache is missing.
set
the same as redis command set
, reset yac cache value
delete / unlink
the same as redis command delete
or unlink
, also delete yac cache
expire
the same as redis command expire
, also reset yac cache expire time
clear
the same as redis command flushdb
, but flush all yac cache
hDel / hGetAll / hMSet / hMGet / hSet / hGet
the same as redis command
setLocalCacheTimeout
set yac cache timeout, set the right value for your scenario. cache invalidation is a big concept to deal with.
getLocalCacheTimeout
get yac cache timeout
All versions of localcache with dependencies
psr/simple-cache Version ^1.0
ext-yac Version >=2.0.0
ext-redis Version >=4.0.0