mysql - How to efficiently invalidate cache? -
i’ve been trying optimize performance 1 behemoth software based on php , mysql. have gone through caching in apache , indexes in mysql not enough. since forms within software built , printed dynamically configuration in database software sends huge number of sql’s , lot of joins slows whole thing when there many concurrent users connected (on average 200-300).
since cannot touch code, have seen mysql-proxy can placed between application server , database server , on there query results can cached accessing redis o memchached via lua. idea cache everything. however, problems invalidating cache. once record updated how invalidate cached result sets?
one of ideas convert sql query md5 , store result key of set. analysis of query , store same md5 key , references table. example:
query:
select * products left join users on products.user_id = user.id
cache instance a
3b98ab273f45af78849db563df6598d1– {result set}
cache instance b
products - 3b98ab273f45af78849db563df6598d1 users - 3b98ab273f45af78849db563df6598d1
so once update or insert or delete issued on of these tables invalidates result sets particular table queried.
i see quite lot of work , wondering if there simpler methods achieve this.
Comments
Post a Comment