Skip to content

Test Redis on NodeJS. (Redis,NodeJS,ioredis,dotenv,node-fetch,Express)

Notifications You must be signed in to change notification settings

andrei1994rus/test-redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

test-redis


This app is test Redis on NodeJS. List is used in database.


Functions

  • Use database (Redis);
  • Get list;
  • Get count of elements;
  • Get element of list by inputted index;
  • Push element/elements into list;
  • Remove element from list;
  • Set element of list;
  • Handle wrong path (404 NOT FOUND);
  • Can delete spaces before and after ',' during execute command lpush;
  • Has index.html to explain about commands.

Commands

  • Lrange - get all elements of list (path: /.netlify/functions/api/person/). Command in Redis: LRANGE person 0 n (also this argument may be -1) - where 'n' is count of elements;
  • Llen - get count of list's elements (path: /.netlify/functions/api/person/count);
  • Lindex - get element of list by inputted index (path: /.netlify/functions/api/person/:index - where ':index' is inputted index);
  • Lset - set inputted element by required index (path: /.netlify/functions/api/person/lset/:index/:elem - where ':index' is required index, ':elem' is inputted element);
  • Lrem - remove inputted element 1 time (path: /.netlify/functions/api/person/lrem/:elem - where ':elem' is element what you need to remove from list). Command in Redis: LREM person -1 element - where 'element' is inputted element;
  • Lpush - push inputted element/elements into begin of list (path: /.netlify/functions/api/person/lpush/:elem - where ':elem' is new element or array of new elements). Command in Redis (one element): LPUSH person element - where 'element' is inputted element. Command in Redis (few elements): LPUSH person element1 element2 ... - where 'element1' is first inputted element, where 'element2' is second inputted element, where '...' is infinite count of new elements (depends on your wish).

Example of use Lpush in browser

One element: /person/lpush/test

Few elements: /person/lpush/test1,test2


Used stack technology

  • NodeJS;
  • Redis;
  • HTML;
  • JS;
  • Libraries: dotenv, Express, ioredis, node-fetch.

URL .