示例#1
0
        /// <summary>
        /// Delay Insert the specified item
        /// </summary>
        /// <param name="item"></param>
        public static void DelayedInsert(this NancyBlackDatabase db, dynamic item)
        {
            var     t = item.GetType();
            dynamic buffer;

            if (_buffers.TryGetValue(t, out buffer) == false)
            {
                buffer = DelayedInsertExt.CreateBuffer(db.DatabaseFileName, t);
                _buffers.AddOrUpdate(t, buffer, new Func <Type, object, object>((tin, o) => o));
            }

            buffer.Add(item);
        }
示例#2
0
        /// <summary>
        /// Changes the delay time for
        /// </summary>
        /// <param name="t"></param>
        /// <param name="delay"></param>
        public static void SetFlushDelay(this NancyBlackDatabase db, Type t, TimeSpan delay)
        {
            dynamic buffer;

            if (_buffers.TryGetValue(t, out buffer))
            {
                buffer.FlushDelay = delay;
            }
            else
            {
                buffer = DelayedInsertExt.CreateBuffer(db.DatabaseFileName, t);
            }
        }