Suppose dal uses php as an example. I used to use php to operate mysql separately. Now I need to squeeze the server and consider adding a redis instance. However, I am confused about the access policies of the two data sources. I hope to help me sort it out. It is better to explain it with pseudo code. Thank you. Suppose dal uses php as an example.
I used to use php to operate mysql separately. Now I need to squeeze the server and consider adding a redis instance. However, I am confused about the access policies of the two data sources. I hope to help me sort it out.
It is better to explain it with pseudo code. Thank you.
Reply content:
Suppose dal uses php as an example.
I used to use php to operate mysql separately. Now I need to squeeze the server and consider adding a redis instance. However, I am confused about the access policies of the two data sources. I hope to help me sort it out.
It is better to explain it with pseudo code. Thank you.
Simply using redis as a cache doesn't have to be written in the DAL (I don't know what the DAL means. I only use DAO, AR, ORM, and heard the name is similar ?), Expand it only in the form of Cache, such as inheriting your Cache class. If you still need to use it for permanent storage, inherit the DAL class and use redis to implement it, if you use a queue, or intersection collection, counters, and so on, you can also use the redis database to implement the existing interface.
Finally, we use a universal portal file to call different implementations through the constructor.
Pseudo code will not write, since PHP directly paste open source project Yii2-redis, look at the ActiveRecord. php and Cache. php, the idea is probably like this.