top-think / top-think/think-orm
模型save后不会自动更新cache
Open
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 437
- Forks
- 188
- PR merge metrics
- No merged PRs in 30d
Description
如下代码,goods_name字段已设置成其他的值,但是最后查询出来的还是修改前的值
$goods = GoodsModel::cache(true,600)->find(100532);
$goods->goods_name = '213123';
$goods->save();//不会更新缓存
dump( GoodsModel::cache(true,600)->find(100532)->toArray());//查询出的goods_name不是213123而是修改之前的
但是直接使用db类操作却不会有问题
$goods = Db::name('goods')->cache(true,600)->find(100532);
$goods['goods_name'] = '123212';
Db::name('goods')->cache(true,600)->update($goods);//会更新缓存
dump(Db::name('goods')->cache(true,600)->find(100532));//查询出goods_name=123212
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two snippets in the issue and compare the model save path with the Db update path when caching is enabled. Trace the cache behavior used by GoodsModel::save() and verify that a subsequent cached find returns the updated goods_name after the fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100