Firefly Official Tutorial Dbentrust using the documentation

Source: Internet
Author: User
Tags memcached

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                                  

<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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.