Пример #1
0
        // 同步加载指定 id 的数据
        protected override byte[] LoadImpl(IDType id)
        {
            string f = Path.Combine(dir, Utils1.MD5(id.ToString()));

            if (File.Exists(f))
            {
                BinaryReader r    = new BinaryReader(new FileStream(f, FileMode.Open));
                byte[]       data = r.ReadBytes((int)r.BaseStream.Length);
                r.Close();
                return(data);
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        // 将缓冲同步落地保存
        protected override void UpdateImpl(IDType id, T d, byte[] buff)
        {
            string       f    = Path.Combine(dir, Utils1.MD5(id.ToString()));
            string       tmpF = tmpF = f + ".tmp";
            BinaryWriter w    = new BinaryWriter(new FileStream(tmpF, FileMode.Create));

            w.Write(buff, 0, buff.Length);
            w.Close();

            if (File.Exists(f))
            {
                File.Delete(f);
            }

            File.Move(tmpF, f);
        }
Пример #3
0
        // 同步删除指定 id 的数据
        protected override void DeleteImpl(IDType id)
        {
            string f = Path.Combine(dir, Utils1.MD5(id.ToString()));

            File.Delete(f);
        }