Firefly Official Tutorial Dbentrust using the documentation

Source: Internet
Author: User
Tags documentation

Original address:

Http://bbs.gameres.com/thread_224185.html

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. Structure Analysis




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, which is realized by inheriting the Memobject class.
Mfkmode class represents the foreign key of the data in the memcached
The Madmin class is a Mmode manager that can obtain an instance of Mmode based on the primary key, representing a table in the database in memcached
The Madminmanager class is the manager of the Madmin object, and in effect manages the records of the tables in the entire library, but the madmin corresponding to this table must be registered here.
3. Examples of Use
1) Read the tables in the database and store them in the memcached




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




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




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

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.