testRedis.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * Created by benzhan on 15/8/10.
  3. */
  4. var oujRedis = require('../framework/lib/oujRedis.js');
  5. var objRedis = oujRedis.init('Web');
  6. var test = objRedis.get('test');
  7. test.then(function(data) {
  8. console.log(data);
  9. objRedis.set('test', data + "1").then(function(data) {
  10. console.log(data);
  11. test = objRedis.get('test');
  12. test.then(function(data) {
  13. console.log(data);
  14. objRedis.disconnect();
  15. }, function(err) {
  16. console.log(err);
  17. objRedis.disconnect();
  18. });
  19. });
  20. }, function(err) {
  21. console.log(err);
  22. });
  23. var pipeline = objRedis.pipeline();
  24. pipeline.exists('foo');
  25. pipeline.set('foo', 'bar');
  26. pipeline.exists('foo');
  27. pipeline.get('foo');
  28. pipeline.del('foo');
  29. pipeline.exists('foo');
  30. test = pipeline.exec();
  31. test.then(function (results) {
  32. // `err` is always null, and `results` is an array of responses
  33. // corresponding to the sequence of queued commands.
  34. // Each response follows the format `[err, result]`.
  35. console.log('pipeline');
  36. console.log(results);
  37. }, function(err) {
  38. console.error(err);
  39. });