memcachier / memjs

A memcache client for node using the binary protocol and SASL authentication
MIT License
197 stars 52 forks source link

avoid calculating hashCode for single server #140

Closed kawanet closed 3 years ago

kawanet commented 3 years ago

hashCode() function runs every time perform() method called. It costs. It should run only when multiple server endpoints are given. This PR skip it when the only one server endpoint is given.

number of servers BEFORE AFTER
single server === 1 calc hashCode() skip hashCode()
multiple servers > 1 calc hashCode() calc hashCode()

In my case, AWS ElastiCache gives a single server endpoint.

saschat commented 3 years ago

@kawanet Thanks for all your PRs and improvements!

Do you see any more coming in the near future? Else we could bump the version and publish it.

kawanet commented 3 years ago

@saschat Thank you for asking it. That's all for the moment.

The module's binary protocol looks working great, by the way. I have a plan to start using it in production from January after some more tests completed. I may have some updates later. Thank you again for providing the module.

kawanet commented 3 years ago

ping

saschat commented 3 years ago

Sorry for the delay, version 1.3.0 is published now.

kawanet commented 3 years ago

My benchmark https://github.com/kawanet/memcached-kvs shows that the new MemJs version 1.3.0 is 2%-9% faster than other node.js libraries of Memcached and memcached-lite. Keyv-Memcache does use MemJs as well. It's bit slow when handling larger Buffer due to JSONB overhead.