Beispiel #1
0
        // get per thread cached db instance by name
        public DBMySqlDB getDB(string name)
        {
            DBMySqlDB db = null;
            ConcurrentDictionary <string, DBMySqlDB> dbs = null;

            // get current thread db instance
            dbs = _dbs.GetOrAdd(Thread.CurrentThread.ManagedThreadId, new ConcurrentDictionary <string, DBMySqlDB>());
            dbs.TryGetValue(name, out db);

            if (db == null)
            {
                dynamic dbconf = null;
                _dbConfs.TryGetValue(name, out dbconf);

                if (dbconf == null)
                {
                    // config not exist
                    return(null);
                }

                db = new DBMySqlDB();
                if (!db.init(dbconf))
                {
                    return(null);
                }

                dbs[name] = db;
            }

            return(db);
        }
Beispiel #2
0
        // create a db instance outside manager, caller is response to maintain the instance
        public DBMySqlDB createDB(string name)
        {
            dynamic   dbconf = null;
            DBMySqlDB db     = null;

            _dbConfs.TryGetValue(name, dbconf);

            if (dbconf == null)
            {
                // config not exist
                return(null);
            }

            db = new DBMySqlDB();
            if (!db.init(dbconf))
            {
                return(null);
            }

            return(db);
        }
Beispiel #3
0
 public AEDBPersistObject(object persistDB, IDBTable table, object memDB, string id, object data, bool isFromDB) : base(table, memDB, id, data, isFromDB)
 {
     _persistDB = (DBMySqlDB)persistDB;
 }