{"action":"created","issue":{"url":"https://api.github.com/repos/nutzam/nutz/issues/844","labels_url":"https://api.github.com/repos/nutzam/nutz/issues/844/labels{/name}","comments_url":"https://api.github.com/repos/nutzam/nutz/issues/844/comments","events_url":"https://api.github.com/repos/nutzam/nutz/issues/844/events","html_url":"https://github.com/nutzam/nutz/issues/844","id":69745580,"number":844,"title":"讨论一下Dao的缓存实现","user":{"login":"wendal","id":589819,"avatar_url":"https://avatars.githubusercontent.com/u/589819?v=3","gravatar_id":"","url":"https://api.github.com/users/wendal","html_url":"https://github.com/wendal","followers_url":"https://api.github.com/users/wendal/followers","following_url":"https://api.github.com/users/wendal/following{/other_user}","gists_url":"https://api.github.com/users/wendal/gists{/gist_id}","starred_url":"https://api.github.com/users/wendal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wendal/subscriptions","organizations_url":"https://api.github.com/users/wendal/orgs","repos_url":"https://api.github.com/users/wendal/repos","events_url":"https://api.github.com/users/wendal/events{/privacy}","received_events_url":"https://api.github.com/users/wendal/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/nutzam/nutz/labels/Dao","name":"Dao","color":"02e10c"},{"url":"https://api.github.com/repos/nutzam/nutz/labels/%E9%9C%80%E6%B1%82","name":"需求","color":"FFFF88"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-04-21T05:11:59Z","updated_at":"2015-05-24T08:20:31Z","closed_at":null,"body":"代码存放到nutzmore项目中\r\n\r\n基本步骤:\r\n1. 如果是select语句,且存在Entity的情况下, 先判断缓存再数据库取值\r\n2. 如果是其他语句,清空对应表的缓存\r\n\r\n依赖:\r\ndruid的sql处理器\r\n\r\n需要添加/修改的内容:\r\n1. 缓存配置注解, 定义缓存名,key组合\r\n2. 缓存实现的接口\r\n3. 捕捉select语句生成的对象(以存入缓存实现中)\r\n\r\n可能遇到的问题:\r\n1. 自定义sql对缓存状态的破坏\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/nutzam/nutz/issues/comments/104990106","html_url":"https://github.com/nutzam/nutz/issues/844#issuecomment-104990106","issue_url":"https://api.github.com/repos/nutzam/nutz/issues/844","id":104990106,"user":{"login":"fangoxyz","id":6936907,"avatar_url":"https://avatars.githubusercontent.com/u/6936907?v=3","gravatar_id":"","url":"https://api.github.com/users/fangoxyz","html_url":"https://github.com/fangoxyz","followers_url":"https://api.github.com/users/fangoxyz/followers","following_url":"https://api.github.com/users/fangoxyz/following{/other_user}","gists_url":"https://api.github.com/users/fangoxyz/gists{/gist_id}","starred_url":"https://api.github.com/users/fangoxyz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fangoxyz/subscriptions","organizations_url":"https://api.github.com/users/fangoxyz/orgs","repos_url":"https://api.github.com/users/fangoxyz/repos","events_url":"https://api.github.com/users/fangoxyz/events{/privacy}","received_events_url":"https://api.github.com/users/fangoxyz/received_events","type":"User","site_admin":false},"created_at":"2015-05-24T08:20:30Z","updated_at":"2015-05-24T08:20:30Z","body":"https://github.com/fangoxyz/DaoCache\r\n实现了一二三级缓存以及多表查询缓存\r\n1.缓存分为一二缓存的意义在于减少缓存清除操作的粒度，当根据主键update或delete时 ，清除一级缓存中的一条数据以及清除二级缓存中的所有数据。\r\n\r\n2.一级缓存的key是主键值，缓存命名:t_user的一级缓存为t_user_L1___ ,一级缓存中存放的是单条记录。\r\n比如 select * from t_user where id=1。判断此条sql语句的数据是否存放在一级缓存中的条件有:\r\n(a).select部分必须是“*”,如select id from t_user where id=1 的数据是不放在一级缓存中的，而是放在二级缓存中。\r\n(b).  t_user必须是一个基本表，不是视图。\r\n(c). select 语句中只涉及一个表，如果select * from t_user inner join t_usergoup on (id);这是不允许存在一级缓存中。\r\n(d).where条件 必须是\"=\" 且 \"=\"号左边字段属于t_user表的主键\r\n\r\n3.二级缓存中存放的是基本表的非主键查询的数据，比如select * from t_user where id>0。二级缓存不包括视图和多表查询的缓存。\r\n\r\n4.三级缓存存放视图和多表查询数据，并且使用cacheLinks的关系关联与二级缓存关联。  多表查询时缓存名使用##连接，如t_user##t_usergroup，当清除t_user表的缓存时会清除缓存名为t_user##t_usergroup的缓存.\r\n "}}