2

I'm running a Game server which uses a Redis database. I'm not familiar with NoSQL Db's.

I'm trying to extract some information from this database but I can't find the commands to do it with redis-cli. For the purpose I've made screenshots using Fastoredis under Windows but the server is running under Debian and I'm using redis-cli as client (Sorry I havn't enough reputation to post image so here a links to my images).

entityinfo

First I want to get from the "table" (don't know if I can call it a table) "entityinfo" all items having the EntityType=Ship. From these items I like to get the information "Shiptype", "EntityName" and "TribeID" (Doesn't show up on the screenshot). I want to save these information in a file called ship.txt.

TribeID

Then from a second table called "tribedata" I want to get all items with the information TribeID and TribeName. I want to save these information in a file called tribe.txt.

This is for a Game Server DB runing under Debian Stretch with latest redis-server (3.2.6) package installed.

I've already tried to use the command redis-cli --csv lrange but I don't really know how it works and that's why I get no results.

Inity
  • 31
  • 1

1 Answers1

1

You can search by values with Redis, but it will not be easy, see this answer

A more simple, but not efficient solution is to:

  • Get all entityinfo keys
  • Loop trough each key, get the value
  • Store it into an array if it's a ship

Example Using Nodejs:

package.json:

{
  "name": "stackoverflow",
  "version": "1.0.0",
  "license": "ISC",
  "dependencies": {
    "redis": "2.8.0"
  }
}
const redis = require("redis");
const { promisify } = require("util");

const options = {
  url: "redis://localhost:6379"
};
const client = redis.createClient(options);
const keysAsync = promisify(client.keys).bind(client);
const hgetAllAsync = promisify(client.hgetall).bind(client);

const isBoat = entity => entity.EntityType && entity.EntityType === "Ship";

const main = async () => {
  const keys = await keysAsync("entityinfo:*");

  const ships = [];
  for (const [index, key] of keys.entries()) {
    const entity = await hgetAllAsync(key);

    if (isBoat(entity)) {
      ships.push({ type: entity.ShipType, name: entity.EntityName });
    }
  }

  console.log(`  >`, ships);
  process.exit(0);
};

try {
  main();
} catch (error) {
  console.error(error);
  process.exit(1);
}

I'm guessing that your game is Atlas, look at this project it's an interactive Map Viewer for Atlas, done by Grapeshot. They are using another method (with scan), to loop trough each entities.

sanghin
  • 398
  • 3
  • 14