1, dbentrust description This module mainly deals with the database and memcached storage. It encapsulates the mapping from memcached data to Python objects. Data stored in memcached can be manipulated in a way that manipulates Python objects, as long as memobject objects of the same name are instantiated in different processes, ensuring that the data in the object is consistent. It also contains a way to synchronize the data in this object to the database. 2, structural parsing &N Bsp , &NB Sp , &NB Sp , &NB Sp &NBSP; <ignore_js_op> The Memobject class specifies the format of the data, all the data is stored in the memcached, in order to distinguish between different data, each data must have its own naming rules. Mmode is the direct mapping class of database to Memcached, which represents a data in the database in memcached, By inheriting the Memobject class to implement the Mfkmode class in memcached to represent the data corresponding to the foreign key Madmin class is the Mmode manager, you can obtain a Mmode instance according to the primary key, In memcached, a table in the database Madminmanager class is the manager of the Madmin object, which is actually the management of the records of the tables in the entire library, but the corresponding madmin of the table must be registered here. 3. Examples of Use 1) Read the tables in the database and store them in the memcached <ignore_js_op> Line 10th, import madmin from Firefly Line 12th, instantiate the Madmin, that is, read the information in the Tb_register table from the database, key is the second parameter, that is, Username,value is the corresponding information Line 13th, writing data to memcached 2) Read the required data from the memcached for operation <ignore_js_op> Line 13th, remove the data object with ID Characterid in the Madmin Manager (data from the Tb_character_matrix table stored in memcached) Mmode (Matrixmmode) Line 14th, the data to be modified Line 15th, change the value of key ' eye ' in the data Object (Matrixmmode) to-1 3) Use of Madmin manager Madminmanager <ignore_js_op> Line 8th, import Madminmanager from Firefly Line 13th, add an instance of the data Object Madmin (tb_matrix_amin) to the Madmin Singleton manager Madminmanager, typically used when the server is turned on Line 14th, synchronize all of the registered Madmin records in the Madminmanager database, and process the expired objects, typically used when the server shuts down (note: Only synchronize data that was previously registered to the instance of the data object Madmin in Madminmanager) |