方维分享系统,有个 你可能还喜欢 的模块,我想再加个 价格关联 的相关分享,然后去分析 分享系统的缓存机制,他的流程;
note.module.php 里面分析getRelatedSharesByShareIdAndTags()
①
$key = 'share/related/'.substr($key,0,2).'/'.substr($key,2,2).'/'.$key;
$result = FS('Delay')->get($key);
$cids[]商品的分类;$tags商品的tag;这两个组合 在/public/data/cache/custem/share/related/2e/6f/2e6f97eedf9e17a188061ea4c****7d2.cache.php
②
$share_ids有的话,
setCache($related_key,$list,SHARE_CACHE_TIME);
生成缓存文件:路径/public/data/cache/custem/share/000/000/097/15/related.cache.php
③
args有值的话,FS('Delay')->create(array('m'=>'share','a'=>'related','args'=>$args));也就是对应的①的FS('Delay')->get($key)
实现sql
$list = FDB::fetchAll('SELECT s.share_id,s.uid,s.content,s.collect_count,s.comment_count,s.create_time,s.cache_data,abs(g.price-'.$price.') as price_cha FROM '.FDB::table('share').' as s inner join '.FDB::table('share_goods').' as g on s.share_id=g.share_id WHERE s.share_id IN ('.implode(',',$share_ids).') order by price_cha asc limit 30');