mirror of https://github.com/ogoun/Zero.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
885 B
30 lines
885 B
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SQLite;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using ZeroLevel.SqLite;
|
|
|
|
namespace ZeroLevel.EventServer
|
|
{
|
|
public class EventRepository
|
|
:BaseSqLiteDB
|
|
{
|
|
private readonly SQLiteConnection _db;
|
|
private readonly ReaderWriterLockSlim _rwLock = new ReaderWriterLockSlim();
|
|
private readonly string _tableName;
|
|
|
|
public EventRepository()
|
|
{
|
|
_tableName = "events";
|
|
|
|
var path = PrepareDb($"{_tableName}.db");
|
|
_db = new SQLiteConnection($"Data Source={path};Version=3;");
|
|
_db.Open();
|
|
|
|
Execute($"CREATE TABLE IF NOT EXISTS {_tableName} (id INTEGER PRIMARY KEY AUTOINCREMENT, key TEXT, body BLOB)", _db);
|
|
Execute($"CREATE INDEX IF NOT EXISTS key_index ON {_tableName} (key)", _db);
|
|
}
|
|
}
|
|
}
|