aumcode / nfx

C# Server UNISTACK framework [MOVED]
https://github.com/agnicore/nfx
Other
391 stars 93 forks source link

can't read data back from MMF #78

Closed unruledboy closed 7 years ago

unruledboy commented 7 years ago

Hi,

I used the sample code from your files : https://github.com/aumcode/nfx/blob/master/Source/Testing/Manual/WinFormsTest/PileForm.cs#L77-L84 and https://github.com/aumcode/nfx/tree/master/Source/NFX/ApplicationModel/Pile

I can add records to the MMF cache, but I couldn't find a way to get the data back, either with tA.Get(key) or tA.AsEnumerable(withValues: true).

      var cache = new LocalCache();
      var pile = new MMFPile(cache);//Pile owned by cache
      pile.DataDirectoryRoot = @"c:\temp\test";
      cache.Pile = pile;
      cache.Configure(null);
      cache.DefaultTableOptions = new TableOptions("*")
      {
        CollisionMode = CollisionMode.Durable
      };
      cache.Start();

      var tA = cache.GetOrCreateTable<int>("A");

      for (int i = 0; i < 10000; i++)
      {
        tA.Put(i, Person.MakeFake());
      }

      DisposableObject.DisposeAndNull(ref cache);
itadapter commented 7 years ago

The LocalCache class does not use pile to store it's key buckets. You get your mmf pile back with data but not the keys. The MMF-backed cache is not a part of oss yet, what you can do for now - reload the keys back to local cache by enumerating through them using pile, but it will be slow depending on the number of object that you store. OR you can save all of the cache keys separately and load them up on startup which is also not automatic.