Suppose the DAL uses PHP for example.
Originally using PHP alone to operate MySQL, now need to press the server, consider adding a redis, but at the same time facing the two data source access strategy generated doubts, hope to help comb.
It's better to explain it in pseudo-code, thank you.
Reply content:
Suppose the DAL uses PHP for example.
Originally using PHP alone to operate MySQL, now need to press the server, consider adding a redis, but at the same time facing the two data source access strategy generated doubts, hope to help comb.
It's better to explain it in pseudo-code, thank you.
Just think of Redis as a cache, no need to write it in the Dal (I don't know what the dal means, just use DAO, Ar,orm, listen to the names are similar things?). ), just to expand it in the form of caching, such as inheriting your cache class, if it is also useful for persistent storage needs, to inherit the Dal class, with Redis to implement it, if used as a queue, or intersection and set, counter, etc., also to the Redis database to implement the existing interface.
Finally, a generic portal file is used to invoke the different implementations by constructing the method.
Pseudo code will not write, since PHP directly paste Open source project Bar Yii2-redis, look at the activerecord.php and cache.php, presumably this is the idea.