kristoff-it / redis-memolock Goto Github PK
View Code? Open in Web Editor NEWRedis MemoLock - Distributed Caching with Promises
License: MIT License
Redis MemoLock - Distributed Caching with Promises
License: MIT License
Checking in to see if that's still coming soon. Thanks!
In the examples when the NewRedisMemoLock
is initialised a 5-15 second lockTimeout is provided.
This is what's passed to SetNX
when acquiring the lock.
However, when I open a terminal into my redis instance and do KEYS *
to list the locks and then TTL ${resourceTag}/lock:${resID}
it returns this:
127.0.0.1:6379> TTL report/lock:123
(integer) 19999999845
When I run it a few seconds later:
127.0.0.1:6379> TTL report/lock:123
(integer) 19999999835
Which seems to suggest the actual TTL applied onto the lock is 2 billion seconds.
This presents an issue running the examples, because nowhere in the RedisMemoLock
actually explicitly frees the lock, once the examples have been called once we can never re-aquire the lock.
Do you have any idea why redis is not respecting the lockTimeout provided by us?
Running redis via docker with default settings.
Redis version=7.0.10, bits=64, commit=00000000, modified=0, pid=1, just started
2023-07-23 01:21:40 1:C 23 Jul 2023 00:21:40.091 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
I have found a way to reliably produce an index out-of-range in the example.
go run extended_example.go
Send two GET requests to the same renewable resorce within a few seconds (so the second request has to wait for the promise of the first request):
GET localhost:8080/report/renewable/123
(wait 2 seconds)
GET localhost:8080/report/renewable/123
Then one of the requests fails with:
panic: runtime error: index out of range [1] with length 1
goroutine 35 [running]:
github.com/kristoff-it/redis-memolock/go/memolock.(*RedisMemoLock).dispatch(0xc00028c0c0)
/Users/oscarvanleusen/go/src/github.com/redis-memolock/go/memolock/RedisMemoLock.go:88 +0x4b9
created by github.com/kristoff-it/redis-memolock/go/memolock.NewRedisMemoLock
/Users/oscarvanleusen/go/src/github.com/redis-memolock/go/memolock/RedisMemoLock.go:125 +0x20a
exit status 2
The same problem can also be reproduced with the /ext/stemmer
and /report/oh-no/
routes. I can't reproduce it with the /query/simple
route though.
If I were to guess, this only affects GetResourceRenewable
and GetResourceExternal
, but not GetResource
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.