目前的freyja在维护缓存的时候是将表分为多个字段,每个字段负责维护与字段有关的缓存。
当字段update的时候去检测是否需要缓存失效。
经过我对这些数据的分析,引入分组概念能加快维护缓存的效率。
例如,大部分数据都是围绕用户产生的,User、Hero、Building 他们都是一对多关系,在这些表当中,大部分查询都是限于当前用户的数据查询。那么按userId分组将大大的减少检索的内容,从而提高维护缓存的效率。
当然其他的表也可以根据自己的情况分组/不分组。
另外也许还会采用single注解减少update操作,被single注解的表明当前字段不会出现在联表查询范围内。那么这个字段的update操作就不需要序列化到数据库,在系统关闭/缓存过期的时候update一次就足够了
[Freyja] [SQL] update t_hero set STATUS = ?,holdNumber = ? where ID = ? [args] 1 100 6769
[Freyja]
14:14:26,718 - 扫描cache: SELECT * FROM t_hero AS h WHERE h.user_id = ? AND STATUS >= 0#@7272
14:14:26,718 - 扫描cache: SELECT * FROM t_hero WHERE user_id = ? AND CITY_ID = 0 AND STATUS IN (0, 1)#@7273
14:14:26,718 - 移除 cache:from Hero where userId = ? and cityId = 0 and status in (0,1)#null#null#0#@7273
14:14:26,718 - 移除 cache:SELECT * FROM t_hero WHERE user_id = ? AND CITY_ID = 0 AND STATUS IN (0, 1)#@7273
14:14:26,718 - 扫描cache: SELECT * FROM t_hero WHERE user_id = ? AND CITY_ID = 0 AND STATUS IN (0, 1)#@7272
14:14:26,718 - 扫描cache: SELECT * FROM t_hero AS t WHERE t.user_id = 7273 AND STATUS >= 0#
14:14:26,718 - 移除 cache:select t.id as id,t.name as name,t.level as level,t.legendFlag as legendFlag,t.status as status,t.cityId as cityId,t.holdNumber as holdNumber,t.battleAtTime as battleAtTime from Hero t where t.userId = 7273 and status >=0#null#null#1#
14:14:26,718 - 扫描cache: SELECT * FROM t_hero AS t WHERE t.user_id = 7272 AND STATUS >= 0#
14:14:26,718 - 扫描cache: SELECT * FROM t_hero AS h WHERE h.user_id = ? AND STATUS >= 0#@7273
14:14:26,718 - 移除 cache:select h.id as id,h.name as name,h.status as status from Hero h where h.userId = ? and status >= 0#null#null#1#@7273
14:14:26,718 - 扫描cache: SELECT * FROM t_hero WHERE user_id = ? AND CITY_ID = 0 AND STATUS IN (0, 1)#@7272
14:14:26,718 - 扫描cache: SELECT * FROM t_hero AS h WHERE h.user_id = ? AND STATUS >= 0#@7272
14:14:26,718 - 扫描cache: SELECT * FROM t_hero WHERE user_id = ? AND CITY_ID = 0 AND STATUS IN (0, 1)#@7272
14:14:26,718 - 扫描cache: SELECT * FROM t_hero AS t WHERE t.user_id = 7273 AND STATUS >= 0#
14:14:26,718 - 移除 cache:select t.id as id,t.name as name,t.level as level,t.legendFlag as legendFlag,t.status as status,t.cityId as cityId,t.holdNumber as holdNumber,t.battleAtTime as battleAtTime from Hero t where t.userId = 7273 and status >=0#null#null#1#
14:14:26,718 - 扫描cache: SELECT * FROM t_hero AS t WHERE t.user_id = 7272 AND STATUS >= 0#
14:14:26,718 - 扫描cache: SELECT * FROM t_hero AS h WHERE h.user_id = ? AND STATUS >= 0#@7273
14:14:26,718 - 移除 cache:select h.id as id,h.name as name,h.status as status from Hero h where h.userId = ? and status >= 0#null#null#1#@7273
一个用户的hero更新,按照现在的需要扫描所有用户的hero,通过分组可以将扫描内容减少到之前的 1/n n为用户数。
7272 和7273 为2个用户的ID
分享到:
相关推荐
NULL 博文链接:https://freyja.iteye.com/blog/1312344
NULL 博文链接:https://freyja.iteye.com/blog/1278881
NULL 博文链接:https://freyja.iteye.com/blog/1315666
NULL 博文链接:https://freyja.iteye.com/blog/1403140
NULL 博文链接:https://freyja.iteye.com/blog/1542821
NULL 博文链接:https://freyja.iteye.com/blog/1274222
NULL 博文链接:https://freyja.iteye.com/blog/1783056
NULL 博文链接:https://freyja.iteye.com/blog/1782960
您提供一个接受组件props和应用程序theme的函数,并返回样式图( (theme, props, helpers) => ({key1: style, key2: style}) ), useStyles将返回类名的地图(像{key1: className, key2: className} )。...
弗雷雅 用于Freyja字幕OCR提取器的Node.js +电子用户界面。 仍处于测试阶段。 所有功能都可用,但您在使用该应用程序时可能会遇到错误/崩溃。 请在 github 问题上报告您在log.log文件中遇到的任何错误。系统要求需要...
FREYJA freyja是一个轻量级的blog系统,使用vue-ssr,首屏在服务端渲染,之后的所有请求都由浏览器自行路由。 文章页只有文章内容在服务端渲染,评论是浏览器ajax加载的。 配合http2多路复用,首屏渲染完成时间可以...
matlab有些代码不运行Freyja仿真器 在MATLAB / Simulink(TM)和SimScape(TM)框架内构建的,适用于多直升机系统的高保真物理模拟器。 Freyja的库元素允许对连接多轴直升机和各种其他对象(例如电缆)的运动树进行...
NULL 博文链接:https://freyja.iteye.com/blog/1982568
NULL 博文链接:https://freyja.iteye.com/blog/2196108
NULL 博文链接:https://freyja.iteye.com/blog/1982568