Giter VIP home page Giter VIP logo

memcache-plus's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

memcache-plus's Issues

additional memcached commands

Hi,

Could you please implement the additional memcached commands:
add, replace, append, prepend, cas, incr/decr?

thx,

losing memcached connection

Hello,
We have a very busy production application that is attempting to update via memcache-plus (approximately 200-250 updates/second). Periodically, we see the connection drop and fail:
Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed at doWrite (_stream_writable.js:406:19) at writeOrBuffer (_stream_writable.js:394:5) at Socket.Writable.write (_stream_writable.js:294:11) at Connection.write (/opt/nisient/lib/node/node_modules/memcache-plus/lib/connection.js:418:21) at Connection.<anonymous> (/opt/nisient/lib/node/node_modules/memcache-plus/lib/connection.js:504:18) at Connection.tryCatcher (/opt/nisient/lib/node/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/opt/nisient/lib/node/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/opt/nisient/lib/node/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromiseCtx (/opt/nisient/lib/node/node_modules/bluebird/js/release/promise.js:641:10) at _drainQueueStep (/opt/nisient/lib/node/node_modules/bluebird/js/release/async.js:97:12) at _drainQueue (/opt/nisient/lib/node/node_modules/bluebird/js/release/async.js:86:9) at Async._drainQueues (/opt/nisient/lib/node/node_modules/bluebird/js/release/async.js:102:5) at Immediate.Async.drainQueues [as _onImmediate] (/opt/nisient/lib/node/node_modules/bluebird/js/release/async.js:15:14) at runCallback (timers.js:705:18) at tryOnImmediate (timers.js:676:5) at processImmediate (timers.js:658:5) Error: Memcache connection lost at /opt/nisient/lib/node/node_modules/memcache-plus/lib/connection.js:157:25 at List.__iterate (/opt/nisient/lib/node/node_modules/immutable/dist/immutable.js:2206:13) at List.forEach (/opt/nisient/lib/node/node_modules/immutable/dist/immutable.js:4381:19) at Connection.destroy (/opt/nisient/lib/node/node_modules/memcache-plus/lib/connection.js:156:24) at Timeout._onTimeout (/opt/nisient/lib/node/node_modules/memcache-plus/lib/connection.js:205:30) at ontimeout (timers.js:436:11) at tryOnTimeout (timers.js:300:5) at listOnTimeout (timers.js:263:5) at Timer.processTimers (timers.js:223:10)
without recovery. Currently using 0.2.21 and about to update to 0.2.22, but need some help in diagnosing the problem as it's causing production issues. Thanks so much in advance, we've come to rely upon this module.
Rob

Nested `Buffer` objects don't serialize correctly

If I cache data that contains a nested Buffer object, such as [Buffer, string], then inside of formatValue() the Buffer.isBuffer(val) check returns false and we fall into the JSON.stringify(val) path:

if (typeof val === 'number') {
value = val.toString();
} else if (Buffer.isBuffer(val)) {
value = val.toString('binary');
} else if (typeof val !== 'string') {
value = JSON.stringify(val);
}

And this results in a JSON string that, when parsed, produces an object that looks like:

[
  {
    type: "Buffer",
    data: "...",
  },
  string
]

which of course is not the same shape as the [Buffer, string] object that was originally registered, which is I believe a bug.

Cannot redefine property: find (incompatibility with connect-rest)

I'm noticing that this throws an error if I attempt to require it after requiring connect-rest. To reproduce, run this script:

var rest = require('connect-rest');
var memcached_plus = require('memcache-plus');

Here's the error on my machine:

TypeError: Cannot redefine property: find
    at Function.defineProperty (native)
    at define (/Users/kirkcp/Documents/interactives/express/node_modules/memcache-plus/node_modules/collections/shim-array.js:56:12)
    at Object.<anonymous> (/Users/kirkcp/Documents/interactives/express/node_modules/memcache-plus/node_modules/collections/shim-array.js:135:1)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/kirkcp/Documents/interactives/express/node_modules/memcache-plus/node_modules/collections/generic-collection.js:272:1)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)

Erroneous key length assertion

Hello, found a problem regarding this code:

misc.assert(key.length < 250, 'Key must be less than 250 characters long');

It asserts on character count rather than string byte length. So keys with characters that occupy 2 bytes will be measured incorrectly, leading to a runtime crash.

Steps to reproduce:

var MemcachePlus = require('memcache-plus');

var client = new MemcachePlus();
var key = Array(250).join('Я');

client.set(key, 'test');

Run with:

DEBUG=* node index.js

Output:

  memcache-plus:client Connect options { autodiscover: false,
  bufferBeforeError: 1000,
  disabled: false,
  hosts: null,
  reconnect: true,
  onNetError: [Function: onNetError],
  queue: true,
  netTimeout: 500,
  backoffLimit: 10000,
  maxValueSize: 1048576 } +0ms
  memcache-plus:client starting connection +3ms
  memcache-plus:client connecting to all hosts +0ms
  memcache-plus:connection connecting to host localhost:11211 +1ms
  memcache-plus:connection successfully (re)connected! +8ms
  memcache-plus:client flushing client write buffer +0ms
  memcache-plus:connection trying to flush buffer for localhost +3ms
  memcache-plus:connection sending: "set ЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯ..." +1ms
  memcache-plus:connection sending: "test" +0ms
  memcache-plus:connection got data: "CLIENT_ERROR bad command line format" and the queue now has "1" elements +1ms
  memcache-plus:connection responded and the queue now has "0" elements +1ms
  memcache-plus:connection got data: "ERROR" and the queue now has "0" elements +0ms
/home/vitalii/projects/mem-test/node_modules/memcache-plus/lib/connection.js:246
    if (deferred.type === 'autodiscovery') {
                 ^

TypeError: Cannot read property 'type' of undefined
    at Connection.read (/home/vitalii/projects/mem-test/node_modules/memcache-plus/lib/connection.js:246:18)
    at Carrier.emit (events.js:198:13)
    at /home/vitalii/projects/mem-test/node_modules/carrier/lib/carrier.js:24:12
    at process._tickCallback (internal/process/next_tick.js:61:11)

Correct check would be using https://nodejs.org/api/buffer.html#buffer_class_method_buffer_bytelength_string_encoding , i guess

`netTimeout` option not propagating from `Client` to `Connection` instances

netTimeout is a supported option which allows clients to modify the time that the cache client waits for a response from the cache server through Bluebird's Promise method, .timeout.

Problem is, netTimeout is not correctly getting passed from the Client class instance to each of the Connection instances. This results in netTimeout getting set to the default value of 500ms.

flush_all not working

Hi,

I'm using this client in a lambda function on Amazon AWS.

I have an ElastiCache Memcached cluster of 2 nodes.
I'm passing these nodes to the connection. (I'm not using the auto discover feature).
The connection, set, get, delete funcionality are working fine.

However the flush functionality is not flushing the data.

memcachePlus = new MemcachePlus( { hosts: memcacheHosts } ); memcachePlus.flush().then(onFlushComplete);

No errors are thrown, but data is still there.

Scenario:
Set a key-value item.
Get by key to make sure it's inserted.
Flush data.
Get by key again which should return null, but instead returns the data.

await memcache.set resolving before write complete

Hello,
We have been chasing down a very low percentage issue (about 100 out of every 1M writes) where the promise resolves from a set before the contents of the cache have changed. We have validated this by:
result = await memcached.set(cacheKey, m1); let delay = await wait(5); let r1 = await memcached.get(cacheKey);
and comparing m1/r1. In this case, the contents are a deeply nested JSON object (about 4-5 levels deep) of around 30kB. The content is effectively the same for all writes, apart from a few simple value changes. We are using 0.2.21 on node 10.12.0. memcached is 1.4.25 Ubuntu. Any suggestions or help gladly appreciated.

Warning: a promise was created in a handler but was not returned from it

I have got a bluebird warning.

Warning: a promise was created in a handler but was not returned from it is occuring at lib/client.jsL170

Warning: a promise was created in a handler but was not returned from it
https://github.com/petkaantonov/bluebird/blob/master/docs/docs/warning-explanations.md

I added a line to client.js:

this.hosts = hosts;
this.connectToHosts();
this.flushBuffer();
+ return Promise.resolve();

and the warning is disappeared though return Promise.resolve() doesn't look good.

Stack traces are like:

Warning: a promise was created in a handler at anonymous> (/home/share/shun_tak/project/node_modules/memcache-plus/lib/client.js:170:14 but was not returned from it, see http://goo.gl/rRqMUw
    at new Promise (/home/share/shun_tak/project/node_modules/bluebird/js/release/promise.js:77:14)
    at Object.exports.defer (/home/share/shun_tak/project/node_modules/memcache-plus/lib/misc.js:15:19)
    at Connection.get (/home/share/shun_tak/project/node_modules/memcache-plus/lib/connection.js:713:25)
    at Client.flushBuffer (/home/share/shun_tak/project/node_modules/memcache-plus/lib/client.js:219:48)
    at Client.<anonymous> (/home/share/shun_tak/project/node_modules/memcache-plus/lib/client.js:170:14)
From previous event:
    at Client.getHostList (/home/share/shun_tak/project/node_modules/memcache-plus/lib/client.js:167:26)
    at Client.connect (/home/share/shun_tak/project/node_modules/memcache-plus/lib/client.js:79:14)
    at new Client (/home/share/shun_tak/project/node_modules/memcache-plus/lib/client.js:61:10)
    at Object.<anonymous> (/home/share/shun_tak/project/handlers/sample.js:9:19)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at AwsInvokeLocal.invokeLocalNodeJs (/usr/lib/node_modules/serverless/lib/plugins/aws/invokeLocal/index.js:79:16)
    at AwsInvokeLocal.invokeLocal (/usr/lib/node_modules/serverless/lib/plugins/aws/invokeLocal/index.js:61:19)
    at processImmediate [as _immediateCallback] (timers.js:383:17)

I will appreciate your help with this situation.

RangeError when trying to use autodiscover

I've tried this in Node versions 4.6.1, 6.2.0, 6.5.0 and 6.9.0:

new MemcachePlus({hosts: [/* my autodiscover endpoint */], autodiscover: true});

My endpoint is of the format: something.cfg.use1.cache.amazonaws.com, i've tried it with and without adding the port (11211) to the end.

I get this exception:

> TypeError: Cannot read property 'key' of undefined
    at Connection.read (/opt/web/node_modules/memcache-plus/lib/connection.js:262:34)
    at emitOne (events.js:96:13)
    at Carrier.emit (events.js:188:7)
    at /opt/web/node_modules/memcache-plus/node_modules/carrier/lib/carrier.js:24:12
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)
> Unhandled rejection RangeError: "port" option should be >= 0 and < 65536: undefined
    at lookupAndConnect (net.js:959:13)
    at Socket.connect (net.js:934:5)
    at Object.exports.connect.exports.createConnection (net.js:74:35)
    at Connection.connect (/opt/web/node_modules/memcache-plus/lib/connection.js:186:27)
    at new Connection (/opt/web/node_modules/memcache-plus/lib/connection.js:136:10)
    at Client.<anonymous> (/opt/web/node_modules/memcache-plus/lib/client.js:186:34)
    at Array.forEach (native)
    at Client.connectToHosts (/opt/web/node_modules/memcache-plus/lib/client.js:181:16)
    at Client.<anonymous> (/opt/web/node_modules/memcache-plus/lib/client.js:169:14)
    at bound (domain.js:280:14)
    at Client.runBound (domain.js:293:12)
    at Client.tryCatcher (/opt/web/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/opt/web/node_modules/bluebird/js/release/promise.js:510:31)
    at Promise._settlePromise (/opt/web/node_modules/bluebird/js/release/promise.js:567:18)
    at Promise._settlePromise0 (/opt/web/node_modules/bluebird/js/release/promise.js:612:10)
    at Promise._settlePromises (/opt/web/node_modules/bluebird/js/release/promise.js:691:18)

statistics

  • stats
  • stats items
  • stats slabs
  • stats sizes

Cannot find module 'chai'

  • client.js:8 Object.
    [buharmetre]/[memcache-plus]/lib/client.js:8:14

as chai is used within client.js, it should be instead listed in dependencies in package.json not devDependencies.

Question: Have any plan for automatic failover?

For example if you delete node from elastiacache memcached cluster while it's being used,
https://github.com/petergoldstein/dalli automatically failover and send traffics to other nodes, Without re-loading autodiscovery.
In general, When there are multiple nodes and if one of node goes "fail" (disconnected for long while... etc) then mark that node as unavailable and use other nodes.

Do you guys have plan to implement this kind of failover?

Cachedump test fails.

Looks that something wrong with cachedump or it's tests.
On my local VM(node v12.20.1, memcached 1.5.6) cachedump test always fails:

1) Client cachedump should work gets cache metadata:
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
Unhandled rejection TypeError: Cannot read property 'key' of undefined
    at /home/roman/memcache-plus/test/client.js:1267:36
    at tryCatcher (/home/roman/memcache-plus/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/roman/memcache-plus/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/home/roman/memcache-plus/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/home/roman/memcache-plus/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/home/roman/memcache-plus/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/home/roman/memcache-plus/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/home/roman/memcache-plus/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/home/roman/memcache-plus/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/home/roman/memcache-plus/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:461:21)

Add support for namespaces

Although memcached doesn't support namespaces or tags natively, it can be built on top of it. They also describe an approach for doing so here.

This would be a great feature addition to memcache-plus without requiring it to be implemented in user land.

not using backoffLimit option parameter

Hello,
I was checking out this repo for a job and i found out that backoffLimit is never sended to the Connection constructor, when having one host. It's just a minor fix, so i'll make the PR for that if it's ok.

thanks!

Connection not ready issue

I'm trying to check if the memcached server is up before I run my app (using bufferBeforeError). I have the following code:

  static testConnection () {
    return new Promise((resolve, reject) => {
      const mc = new MemcachePlus({
        hosts: ['localhost:11211'],
        bufferBeforeError: 0
      })

      // I also just tried return mc.set(..) without the outer promise
      mc.set('startup', 'true').then(resolve).catch(reject)
    })
  }

But I keep getting the following thrown/rejected:

Error: Connection is not ready, either not connected yet or disconnected
    at Client.run (/Volumes/sixfive-cs/vault/node_modules/memcache-plus/lib/client.js:467:31)
    at Client.set (/Volumes/sixfive-cs/vault/node_modules/memcache-plus/lib/client.js:307:17)
    at /Volumes/sixfive-cs/vault/lib/TempStorage.js:63:10
    at Function.testConnection (/Volumes/sixfive-cs/vault/lib/TempStorage.js:57:12)
    at Object.<anonymous> (/Volumes/sixfive-cs/vault/bin/vault-server.js:12:13)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.runMain (module.js:575:10)
    at run (node.js:348:7)
    at startup (node.js:140:9)
    at node.js:463:3

My memcached server is running; when I switch to an older branch of my code using the memcached module, things work

Error: Memcache returned an error: %s

  let s1 = await memInst.set(key5, '10abc');
  await memInst.increase(key5);

when key's value is not integer, get the wrong error.
output : Error: Memcache returned an error: %s

Unix domain socket connection(IPC) support

Hi there,

Is it possible to connect to the memcached configured to work via unix socket?

I can't see any details whether it is possible in docs.
Also tried to specify path to socket in host option like this:

hosts: ['/var/run/memcached/memcached.sock:0']

but got an error:

Error: getaddrinfo ENOTFOUND /var/run/memcached/memcached.sock
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26) {
  errno: -3008,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: '/var/run/memcached/memcached.sock'
}

misc.defer question

While checking the code found out something what I can't understand:

In misc.js we have:

exports.defer = function defer(key) {
    key = key || null;

    var resolve, reject;
    var promise = new Promise(function() {
        resolve = arguments[0];
        reject = arguments[1];
    });
    return {
        key: key,
        resolve: resolve,
        reject: reject,
        promise: promise
    };
};

Then in connection.js in set/cas/add/replace/append/prepend methods there is the following code:

            var deferred = misc.defer(key);
            deferred.key = key;

Looks that we set the same value for key property two times: in defer func and after it return.
Is it really necessary to set key property the same value twice?

error when hosts array uses process.env for lambda/claudiajs

const mc = new memcached({hosts: [process.env.memcache], autodiscover: true})

babel src --out-dir bin

src/api.js -> bin/api.js
validating package
TypeError: Cannot read property 'split' of undefined
at Client.splitHost (/private/var/folders/w4/0_jcj9dd67g3ycr39nbzp8kh0000gn/T/9b8b4587-e1c6-4219-a679-a574b6c692fc/node_modules/memcache-plus/lib/client.js:230:19)
at Client. (/private/var/folders/w4/0_jcj9dd67g3ycr39nbzp8kh0000gn/T/9b8b4587-e1c6-4219-a679-a574b6c692fc/node_modules/memcache-plus/lib/client.js:153:22)
at Array.map (native)
at Client.getHostList (/private/var/folders/w4/0_jcj9dd67g3ycr39nbzp8kh0000gn/T/9b8b4587-e1c6-4219-a679-a574b6c692fc/node_modules/memcache-plus/lib/client.js:152:35)
at Client.connect (/private/var/folders/w4/0_jcj9dd67g3ycr39nbzp8kh0000gn/T/9b8b4587-e1c6-4219-a679-a574b6c692fc/node_modules/memcache-plus/lib/client.js:79:14)
at new Client (/private/var/folders/w4/0_jcj9dd67g3ycr39nbzp8kh0000gn/T/9b8b4587-e1c6-4219-a679-a574b6c692fc/node_modules/memcache-plus/lib/client.js:61:10)
at Object. (/private/var/folders/w4/0_jcj9dd67g3ycr39nbzp8kh0000gn/T/9b8b4587-e1c6-4219-a679-a574b6c692fc/bin/api.js:68:12)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at validatePackage (/Users/m/.npm-packages/lib/node_modules/claudia/src/tasks/validate-package.js:15:15)
at initEnvVarsFromOptions.then.then.then.then.then.then.then.dir (/Users/m/.npm-packages/lib/node_modules/claudia/src/commands/update.js:140:10)

Disconnect method

Hello,

Firstly, let me thank you for developing the great plugin.

However, there is a one functionality that I miss in order to use the plugin on Lambda - disconnect(). Unfortunately, AWS Lambdas has to clear all the connections in order to finish execution - this includes memcached connections as well. Currently, the Lambdas are timing out due to connection working in a background.

Would you mind providing such function? Alternatively, I'll try to make a PR for that

Best regards,
Rafal

version isn't a promise.

If you're not with queue enabled, version will mostly fail, because it isn't a promise.

It should be a promise executed after the server connect, because you can't know the version if the server isn't connected.

update `chai.js` to current version to be able to `use strict` mode

please, either:

  • update chai.js dep to current version so that we can use your lib with use strict mode, or
  • get rid of the chai.js dep (which is a heavy/large lib not meant to be used in production, IMHO) in your lib completely and re-impl the few assert checks on your own (preferred)

Touch method

Does this library support memcache touch method?

Handle Reconnect

Hi!

I want to provide some functionality to my application while using memcache-plus library.

I'm currently using the library as part of my project, also I've MemCachier (heroku add-on) as my cache's server. The thing is that I need to authenticate to the server and I did something like proposed here: https://www.memcachier.com/documentation/supported-protocols-ascii-binary. Basically, I'm setting a cache item right after the connection attempt with key=username and value=password so it can establish connection. The issue that I have been experiencing is how to deal with reconnection if the server has any failure, is there a way to set a callback function when trying to reconnect? I need to set that username/password item again in order to avoid connection failure.

I will really appreciate any help that you can provide, by the way great work with the library!

Thank you

Merge pull request?

Hi,
I've pushed a pull request some time ago. I wonder if this project is being maintained, if not, I need to push this to NPM as a new project, that I would definitely try to avoid.
Thank you!

Could you add a method to get all the keys ? Or tell me how to implement.

Hi, I'm trying to build a Memcached desktop, and I need to fetch all the keys stored in Memcached.

Because Memcached's cachedump command can only dump the COLD item, so I need to use the lru_crawler metadump command to fetch all keys. See this link

I trying to add such method by myself.
First, I add a keys method in client.js

Client.prototype.keys = function(cb) {
    return this.run('lru_crawler metadump all', [], cb);
};

Second, I try to add lru_crawler metadump all method for Connection in connection.js

Connection.prototype['lru_crawler metadump all'] = function() {
 // How to implement ? 
};

Now, how to deal with the response data in lru_crawler metadump all is complicated for me, so can you add such method or tell me how to implement ?
Thanks.


I'm a develop from China, so please forgive me English :)

Can onNetError messages be a promise rejection instead as part of the method call?

I'm trying to port my memcached code over to memcached-plus, and it does not seem that the commands reject when there are server issues, and instead onNetError seems to be the catch-all.

The problem I'm having is that the memcached library commands can return an error in the callback, which I generally use as part of my promise rejection.

However, with memcached-plus, the lib call just hangs there, as if waiting to resolve indefinitely if I shut down the memcached server mid-transaction. My fear is that if the server is down, these promises will continue to queue up with heavy usage.

Ideally I'd like the error to be a rejection on the promise. Is that possible to do?

Here's what I'm trying to do:

  function failure (reject, err) {
    // do some error handling then have a custom error be caught downstream
   // *including server net issues*

   ...
    reject(getResponseObj(DB_FAILURE))
  }
...

 // assume this is a method in my memcache client
  del (key) {
    return new Promise ((resolve, reject) => {
      this.memcached.delete(key).then(resolve).catch((err) => failure(reject, err))
    })
  }

TypeError: Cannot read property 'type' of undefined

It crashes with the stack trace as below:

node_modules/memcache-plus/lib/connection.js:246
    if (deferred.type === 'autodiscovery') {
                 ^

TypeError: Cannot read property 'type' of undefined
    at Connection.read (node_modules/memcache-plus/lib/connection.js:246:18)
    at Carrier.emit (events.js:315:20)
    at Carrier.EventEmitter.emit (domain.js:486:12)
    at node_modules/carrier/lib/carrier.js:24:12
    at processTicksAndRejections (internal/process/task_queues.js:75:11)

I'm running a benchmark script which calls many get/set/append/remove commands.
It works in most cases, and crashes in other cases at the same environment.

  • node v14.15.1
  • memcached (server) 1.5.22
  • memcache-plus (client) 0.2.21

Can you move chai from deps to devDeps?

It's usually a devDep and it's a bit odd to see it installed as part of a production install. I can understand maybe if you're going to run tests before prod is started, but if you're going to do that, you'd probably have the lib at the application level, not at this module level.

Unwind and allow non-string values

See this for more details on current implementation.

Turns out, we can use the Memcached flags in order to implement the "what gets put in gets pulled out" functionality. This may not be entirely compatible with another library as they could use the flags for something different, but it seems this is the most ideal solution.

I will evaluate other libraries and see if there is some consensus as to the value of these flags to indicate type.

This is not entirely a prerequisite for implementing incr/decr but generally needed and a good idea.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.