
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
github.com/ncghost1/redis-replicalock
Advanced tools
A distributed lock idea implemented by redis and golang.It is more secure than a simple redis distributed lock.
It is still in the experimental stage.
Welcome to testing ReplicaLock:
go get github.com/ncghost1/Redis-ReplicaLock
The implementation is almost the same as that of RedissonLock,but "pubsub" is not used here. In RedissonLock, a unlocked message is sent through the channel to the thread that has not acquired the lock.The implementation here simply makes a loop to try to acquire the lock.The most important differences is ReplicaLock uses the "WAIT" command to wait for all replicas to synchronize.When all replicas have completed writing the lock key, then we think we acquire the lock.
The following is an abstract example of a client successfully acquiring replicalock:
Because redis currently does not support the use of the "WAIT" command in lua scripts,we can only send the "WAIT" command to the redis master node after setting the lock successfully.I know that the current implementation may be a little weird, but I just want to show this idea.
An obvious problem about ReplicaLock: lock acquisition may fail due to network delay between master and replica, or the replicas is blocked due to slow query and cannot be synchronized.
This is to prevent lock loss after failover because the replica has not yet completed synchronization with the master node.
A simple example of using ReplicaLock:
func main() {
// We use "redigo" to connect to redis
Conn, err := redis.Dial("tcp", ":6379")
if err != nil {
panic(err)
}
Replock, err := ReplicaLock.New(Conn)
if err != nil {
panic(err)
}
// 'WAIT' Command 'timeout' is 1s, ReplicaLock's lease time is 30s.
err = Replock.Lock(1, 30, "s")
if err != nil {
panic(err)
}
Replock.Unlock()
}
ä¸ćäťçťďźBlogďźďźhttps://www.eririspace.cn/2022/06/19/ReplicaLock/
FAQs
Unknown package
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: whatâs affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.