Firefly Reference Example – Dbentrust Example Instruction - 9miao/Firefly GitHub Wiki
This example instruction article shows the data processing between Firefly and MySQL or memcached, so we need to prepare database in advance.
(Database tool is SQLyogEnt)
1. Create Database
2. Create Table
Here is a simple player table:
The sql sentence in line 18 could be operation on database of any valid sql sentence. In this example, the sql sentence means querying player 100001’s level in player table, runs file:
The print result 40 is same with the number in database. (If you want to know the reason why the result is tuple, see details from MySQLdb module usage in python, there are many tutorials on internet)
We must ensure the normal operation of memcached service before running this example, we have published articles about memcached installation and configuration, and so there is no more further explanation about memcached. Now we run the file:
Line 43 and 44: synchronizing player table data in database to memcached.
Line 46: registering player table data to MAdminManager which we have mentioned before, it’s essentially like “library” in database and manages all “table”.
Line 55: synchronizing all registered data in MAdminManger to database, usually for daily game data backup (It’s for the purpose of avoiding data loss caused by server shutdown due to special accidents. But we suggest you set a longer interval time on account of its high performance consumption) and data backup before server shutdown.
Run file:
We can see the data of levels in memcached has been altered from 40 to 20, now we take a look at the situation in the database:
It also had been successfully altered.









