You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As part of a tuned-for-throughput version of the tracker, avoiding disk accesses unlocks some extra potential.
We can achieve this by implementing the IStorage interface (this can be done dynamically). We should provide an option for this out of the box.
It'd look like this:
using Snowplow.Tracker.Storage;
using System;
using System.Collections.Generic;
using System.Linq;
...
public class MemoryStorage : IStorage
{
private List<string> _items = new List<string>(1000);
public int TotalItems => _items.Count;
public bool Delete(List<string> idList)
{
var ids = (from i in idList select int.Parse(i)).OrderByDescending(x=>x).ToList();
ids.ForEach(id => _items.RemoveAt(id));
return true;
}
public void Put(string item)
{
_items.Insert(0, item);
}
public List<StorageRecord> TakeLast(int n)
{
int totalBack = Math.Min(_items.Count(), n);
int startIndex = _items.Count() - totalBack;
var last = new List<StorageRecord>(totalBack);
for (int idx=startIndex; idx<_items.Count(); idx++)
{
var item = new StorageRecord { Id = idx.ToString(), Item = _items[idx] };
last.Add(item);
}
return last;
}
}
The text was updated successfully, but these errors were encountered:
Switch to making the Queue in memory, as there is no need to use the "PersistentQueue" concept when building an in memory buffer option. Also much easier to make this thread safe.
As part of a tuned-for-throughput version of the tracker, avoiding disk accesses unlocks some extra potential.
We can achieve this by implementing the
IStorage
interface (this can be done dynamically). We should provide an option for this out of the box.It'd look like this:
The text was updated successfully, but these errors were encountered: