Redis backend works.
This commit is contained in:
parent
e6ddbaac62
commit
c300c9995f
|
@ -21,6 +21,11 @@
|
|||
}
|
||||
},
|
||||
"database" : {
|
||||
"type" : "redis",
|
||||
"redis" : {
|
||||
"address" : "127.0.0.1",
|
||||
"port" : "6379"
|
||||
}
|
||||
|
||||
},
|
||||
"admin" : {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module server.accounts;
|
||||
module server.accounts.base;
|
||||
|
||||
/**
|
||||
* This represents the accounts management system of
|
|
@ -1,13 +1,13 @@
|
|||
module server.redis;
|
||||
module server.accounts.redis;
|
||||
|
||||
import vibe.vibe;
|
||||
import server.accounts : BesterDataStore;
|
||||
import server.accounts.base : BesterDataStore;
|
||||
|
||||
/**
|
||||
* This represents a Redis datastore for the Bester
|
||||
* server's account management system.
|
||||
*/
|
||||
public final class RedisDatastore : BesterDataStore
|
||||
public final class RedisDataStore : BesterDataStore
|
||||
{
|
||||
|
||||
/**
|
||||
|
@ -30,6 +30,13 @@ public final class RedisDatastore : BesterDataStore
|
|||
{
|
||||
redisClient = new RedisClient(address, port);
|
||||
redisDatabase = redisClient.getDatabase(0);
|
||||
// createAccount("deavmi", "poes");
|
||||
}
|
||||
|
||||
override public bool userExists(string username)
|
||||
{
|
||||
/* TODO: Implement me */
|
||||
return true;
|
||||
}
|
||||
|
||||
override public bool authenticate(string username, string password)
|
|
@ -11,8 +11,8 @@ import handlers.handler : MessageHandler;
|
|||
import listeners.listener : BesterListener;
|
||||
import connection.connection : BesterConnection;
|
||||
import server.informer.informer : BesterInformer;
|
||||
import server.accounts : BesterDataStore;
|
||||
|
||||
import server.accounts.base : BesterDataStore;
|
||||
import server.accounts.redis : RedisDataStore;
|
||||
|
||||
/**
|
||||
* Represents an instance of a Bester server.
|
||||
|
@ -116,7 +116,21 @@ public final class BesterServer
|
|||
/* TODO: Add comment, implement me */
|
||||
private void setupDatabase(JSONValue databaseBlock)
|
||||
{
|
||||
|
||||
/* Get the type */
|
||||
string dbType = databaseBlock["type"].str();
|
||||
|
||||
if(cmp(dbType, "redis") == 0)
|
||||
{
|
||||
/* get the redis block */
|
||||
JSONValue redisBlock = databaseBlock["redis"];
|
||||
|
||||
/* Get information */
|
||||
string address = redisBlock["address"].str();
|
||||
ushort port = to!(ushort)(redisBlock["port"].str());
|
||||
|
||||
/* Create the redis datastore */
|
||||
dataStore = new RedisDataStore(address, port);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue