Download the PHP package light-speak/laravel_model_cache without Composer
On this page you can find all versions of the php package light-speak/laravel_model_cache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download light-speak/laravel_model_cache
More information about light-speak/laravel_model_cache
Files in light-speak/laravel_model_cache
Package laravel_model_cache
Short Description 基于Redis的laravel模型数值缓存,可以减少并发修改对数据库的压力,减少数据库事务锁的使用
License MIT
Homepage https://github.com/light-speak/laravel_model_cache
Informations about the package laravel_model_cache
Laravel Model Cache
A caching plugin based on Laravel ORM and Redis Cache, relying on queue's model attribute caching
Hold Model instance, proxy fields, use cache modification
Notice!
Data modification is only applicable to numeric types, and the operation is performed by 1000 times, please pay attention to the precision
Install
`
illustrate
This plug-in all uses Cache. The Redis storage function used by Cache is to proxy a field of an object of a certain model, and use Cache to maintain it for a period of time (the default is 15 seconds) All internal modifications are made in the Cache to optimize performance
- Modify the cache for 15 seconds
- Read cache for 3~24 hours
use
- A queue has been added to the queue, named model-cache, which is used to maintain fields
- Embed in the Model class that needs to be used
`
- call the cache() method after the original model
`
- Start using it normally
Detailed usage
Modify data and use plugins for model proxying
`
Call the cache method of the Model, return a CacheModel instance, and at the same time have the return type of the Model instance itself, without affecting the IDE prompt
`
Use incrementByCache and decrementByCache to modify values
At this time, the regular model Wallet::query()->first()->balance will also get the latest cached data
`
CacheModel object and Model try to keep consistency
Transactions
`