Coder Social home page Coder Social logo

kristoff-it / redis-memolock Goto Github PK

View Code? Open in Web Editor NEW
76.0 3.0 11.0 100 KB

Redis MemoLock - Distributed Caching with Promises

License: MIT License

Go 38.92% Python 3.01% C# 58.06%
memolock redis distributed-cache memoization distributed-memoization promise future go

redis-memolock'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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

redis-memolock's Issues

Lock TTL is 2 billion seconds

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?

Redis Version

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

Index out-of-range panic in examples

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.

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.