New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

moon-bucket

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moon-bucket - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

.bin/compile-sha

4

index.js
var fs = require('fs');
var scripts = require('./sha');
var client;

@@ -29,3 +30,4 @@

fs.readFile('./scripts/join.lua', 'utf8', function(err, script) {
client.eval([script, numKeys, keys, hashNamespace, limit], function(err, res) {
console.log(scripts['join']);
client.evalsha([scripts['join'], numKeys, keys, hashNamespace, limit], function(err, res) {
var reply;

@@ -32,0 +34,0 @@

{
"name": "moon-bucket",
"version": "0.0.1",
"version": "0.0.2",
"description": "A bucket of Lua scripts for Redis",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -91,2 +91,17 @@ # :honey_pot: moon-bucket :last_quarter_moon_with_face:

## Technical stuff
Internally when using node.js to call any of the methods available (like `join`), we're actually calling node redis' `evalsha` method on the corresponding sha1 hash in `/sha/index.js`. This is more performant, because we don't have to actually read any files from the file system (in other words, we never make a call to read anything from the `scripts` directory directly; instead, we just make redis evaluate the sha1 hash of the script). So, `moonBucket.join(/* args */)` actually calls something like `redis-cli evalsha b0eff2712326fb5b1cda561a013a0fcc16cb8d85 [...args]`:
```
// ./sha/index.js
module.exports = {
// this is the hash of the corresponding lua script
"join":"b0eff2712326fb5b1cda561a013a0fcc16cb8d85"
};
```
If you want to add your own script to `scripts`, you'll need to implement the method in `./index.js` and then run `./.bin/compile-sha` in order to re-create the sha map.
## What's in a name?

@@ -93,0 +108,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc