cache.js 714 B

12345678910111213141516171819
  1. 'use strict';
  2. // ! ! ! TEMPORARY ! ! !
  3. // this is a temporary placeholder for holding cached data until we get Redis implemented
  4. const tables = {};
  5. const lib = {
  6. addTable: (tableName) => tables[tableName] = [],
  7. addRow: (tableName, data) => tables[tableName].push(data),
  8. delTable: (tableName) => delete tables[tableName],
  9. delRow: (tableName, index) => tables[tableName].splice(index),
  10. getRow: (tableName, index) => tables[tableName][index],
  11. getAllRows: (tableName) => tables[tableName],
  12. findRow: (tableName, key, value) => tables[tableName].find((row) => row[key] == value),
  13. findRowIndex: (tableName, key, value) => tables[tableName].indexOf(lib.findRow(tableName, key, value))
  14. };
  15. module.exports = lib;