signalbot
signalbot copied to clipboard
add storage functions, use phonenumbers
Hey,
because the current implementation of storage.read()
or storage.save()
do not work well when they run simultaneously i added the storage.smembers()
and storage.sadd()
capabilities from redis to the RedisStorage
and InMemoryStorage
classes.
the later is untested, though.
smembers
- list the set of stored data
sadd
- add item to the end of the existing data
i have a command that fetches content from an website. this takes time. to make sure a user never receives the same post twice i used to:
- storage.read()
- do stuff
- storage_result.append(new_id)
- storage.save()
if the user runs the same command twice in a row it might happen that both coroutines read the same data and only the last one is actually saved.
now smembers
and sadd
will handle the "append" and this eliminates the race condition.
i also quickly implemented phonenumbers
(#29)
EDIT: typo