Saravanan666/pypi-org huggingface dataset:
Package: redis-extending-lock
Lock that prolongs itself from time to time and cancels current task if used
as async context manager.Usageimportasyncioimportloggingfromredis.asyncioimportRedisfromredis_extending_lockimportExtendingLockasyncdefmain():redis=Redis.from_url('redis://:hackme@localhost:6379/0')lock=ExtendingLock(redis,'example',timeout=2,# optional, if not specified explicitly# would be half of timeoutextend_interval=1,blocking_timeout=0,)asyncwithlock:# your long-running task,# would be cancelled if lock would be not able to extend# for some reasonawaitasyncio.Future()logging.basicConfig(level=logging.DEBUG)asyncio.run(main())Lock can be also used without context manager:importasyncioimportloggingfromredis.asyncioimportRedisfromredis_extending_lockimportExtendingLockasyncdefmain():redis=Redis.from_url('redis://:hackme@localhost:6379/0')lock=ExtendingLock(redis,'example',timeout=2,blocking_timeout=0,)awaitlock.acquire()awaitasyncio.sleep(5)awaitlock.release()logging.basicConfig(level=logging.DEBUG)asyncio.run(main())How to developmake devenv- configure the development environmentpoetry shellorsource .venv/bin/activate- activate virtualenvmake lint- syntax & code style checkmake codestyle- reformat codemake test- test this projectmake build- build this projectVersioningThis software followsSemantic Versioning.Version is represented using MAJOR.MINOR.PATCH numbers, increment the:MAJOR version when you make incompatible API changesMINOR version when you add functionality in a backwards compatible mannerPATCH version when you make backwards compatible bug fixesAdditional labels for pre-release and build metadata are available as
extensions to the MAJOR.MINOR.PATCH format.In this case, the package version is assigned automatically withpoem-plugins,
it using on the tag in the repository as a major and minor and the counter,
which takes the number of commits between tag to the head of branch.
Package: redis-file
RedisFile===============This is a simple hack to allow the writing to redis as if it wasjust file object in python.Usage-----# Import and open up a ne "file"from redisfile import RedisFilef = RedisFile("myrediskey")# Write some lines to the "file"f.write('hello')f.writelines('world')f.writelines('YourAwesome')# Read the whole fileprint f.read()# Reading a file from the end shows no dataprint f.read()# seek to the start of the filef.seek(0)# Read a single lineprint f.readline()# Read the restprint f.read()# "close" will delete all the dataf.close()Installation------------Installation is simple too::$ pip install redis-file
Package: redis-funnel
redis-funnelA distributed funnel middleware based on redis, management ui included.InstallationYou can installredis-funnelsimply withpip:pip install redis-funnelGetting StartedSuppose you have a function nameddummyruns across many processes, and executes very quickly:importtimedefdummy():returntime.time()whileTrue:printdummy()you wants to restrict its execution speed with a limited qps, e.g. 100:importtimefromredis_funnel.distributedimportqps_factoryqps=qps_factory(host="localhost",port=6379,db=0)@qps("1000001","test",100)defdummy():returntime.time()whileTrue:printdummy()Warning: a redis server should be started first and listening on localhost:6379.Also, if functiondummyjust runs in a single process, then you can just useqpsdecorator based on local memory, in which case you don't need a redis server running first:importtimefromredis_funnel.localimportqps@qps(100)defdummy():returntime.time()whileTrue:printdummy()Management UITBDAuthorredis-funnel is developed and maintained by fanwei.zeng (stayblank@gmail.com). It can be found here:https://github.com/PurpleSun/redis_funnel
Package: redis-gadgets
# redis-gadgetsThis is a collection of helper tools built on top of redis.# Note On TestingMost of the code here is a thin wrapper over a few redis calls.  Testing it
without connecting to redis is pretty useless, as such.  To that end, the tests
make (default) redis connections to pass into the barious tools.  These tests
are destructive.  If you’re running the tests, either override the redis
connection or run it on a machine where you don’t mind clobbering a redis db.Pull requests with a better way to do this are welcome.# Unique trackerThis tool uses redis bit sets to track unique events per day.  The tool maps
between arbitrary string ids and bit offsets, within a namespace (i.e. a given
id-namespace pair maps to a unique bit offset).  This allows for a relatively
compact offset space while still enabling tracking of multiple things, e.g.
unique users viewing pages and unique pages viewed.  There is a default
namespace ‘global’ if you don’t need this feature.Events are tracked on day granularity, so the same id-event pairing will only
be counted once per day. Counts can then be prodouced for arbitrary date
ranges, using bitwise logical operators.  These rollups are cached with a redis
expiration timer.
Package: redisgetapi
InstallationInstall the package from PyPi withpip3 install redisgetapi.UsageThe redis-get-api package comes handy when you want to use api endpoints that have restricted rate limits. It doesexactly that by enforcing rate limits while preserving persistence in the local redis database for the required time limit.For instance if you are building upon twitter, and you intend to search tweets, you are only allowed say 450 requests within any
15 minutes (900 seconds) interval. This package will fetch the first result and cache it for the next 15 minutes when you are not allowed to hit the twitter APIdirectly.Requirements and parametersYou must install redis to use this application. You can use the application as a commandline interface for testing purposes, or within your scipt. The default parameters for redis host and port are 'localhost' and 6379 respectively. The other parameters arethe url to be fetched and the expiry in seconds.Specific use caseLet the parameters be:url = 'http://some/url/with/{your_api_key}/and/some/end_point/'
port = 6379 # unless you have your redis-server in a different port, this is the default
host = localhost
expiry = 300 # this is 5 minutes in secondsCall the application as followsfrom redisgetapi.fetch import RedisEndPoint, cli_call, script_call # there are more functions thereThen you can define the function in your script as follows:def NgrokUrl(url,host,port,expire):
	return script_call(url,host,port,expire)

print(NgrokUrl(url,host,port,expire))NB: The default variable in which redisgetapi is holding the response is 'res'
Package: redisgraph
redisgraph-pyRedisGraph python clientExample: Using the Python ClientimportredisfromredisgraphimportNode,Edge,Graph,Pathr=redis.Redis(host='localhost',port=6379)redis_graph=Graph('social',r)john=Node(label='person',properties={'name':'John Doe','age':33,'gender':'male','status':'single'})redis_graph.add_node(john)japan=Node(label='country',properties={'name':'Japan'})redis_graph.add_node(japan)edge=Edge(john,'visited',japan,properties={'purpose':'pleasure'})redis_graph.add_edge(edge)redis_graph.commit()query="""MATCH (p:person)-[v:visited {purpose:"pleasure"}]->(c:country)RETURN p.name, p.age, v.purpose, c.name"""result=redis_graph.query(query)# Print resultsetresult.pretty_print()# Use parametersparams={'purpose':"pleasure"}query="""MATCH (p:person)-[v:visited {purpose:$purpose}]->(c:country)RETURN p.name, p.age, v.purpose, c.name"""result=redis_graph.query(query,params)# Print resultsetresult.pretty_print()# Use query timeout to raise an exception if the query takes over 10 millisecondsresult=redis_graph.query(query,params,timeout=10)# Iterate through resultsetforrecordinresult.result_set:person_name=record[0]person_age=record[1]visit_purpose=record[2]country_name=record[3]query="""MATCH p = (:person)-[:visited {purpose:"pleasure"}]->(:country) RETURN p"""result=redis_graph.query(query)# Iterate through resultsetforrecordinresult.result_set:path=record[0]print(path)# All done, remove graph.redis_graph.delete()InstallingInstall official releasepip install redisgraphInstall latest release (Aligned with RedisGraph master)pip install git+https://github.com/RedisGraph/redisgraph-py.git@masterInstall for development in envCreate a virtualenv to manage your python dependencies, and ensure it's active.virtualenv -v venv; source venv/bin/activateInstallpypoetryto manage your dependencies.pip install poetryInstall dependencies.poetry installtoxruns all code linters as its default target.
Package: redis_graph
redis_graphredis_graph implements a graph database on top of Redis.Requires:Redis 2.0+Newest version of redis-pyhttp://github.com/andymccurdy/redis-pyredis_wraphttp://pypi.python.org/pypi/redis_wrapRelated:Blog post about redis_graph:http://amix.dk/blog/post/19592#redis-graph-Graph-database-for-PythonExamplesExample of creating edges between nodes:from redis_graph import *

add_edge(from_node='frodo', to_node='gandalf')

assert has_edge(from_node='frodo',
                to_node='gandalf') == True

assert list(neighbors('frodo')) == ['gandalf']

delete_edge(from_node='frodo',
            to_node='gandalf')

assert has_edge(from_node='frodo',
                to_node='gandalf') == FalseExample of node and edge values:from redis_graph import *

set_node_value('frodo', '1')
assert get_node_value('frodo') == '1'

set_edge_value('frodo_baggins', '2')
assert get_edge_value('frodo_baggins') == '2'Copyright: 2010 by amix
License: BSD.
Package: redisGroupMsg
Recently, I’m going to do something like chat software. After a lot of testing, I’ve done this thing.Performance is 13 times faster than py direct circular transmissioninstallpip install redisGroupMsgpush msgpythonfrom redisGroupMsg import redisMessage

r = redisMessage()

if __name__ == '__main__':
    for a in range(1,10):
        e = "id:"+str(a)
        # add queue of group
        # r.addGroup("test",e)
        # send message in group queue
        # r.sendGroup("test",e)
        # remove queue on group
        r.removeGroup("test",e)pop msgpythonfrom redisGroupMsg import redisMessage
r = redisMessage()

if __name__ == '__main__':
    conn = r.conn
    msg = conn.rpop("id:1")
    print(msg)
Package: redisgrpc
Redis gRPC ⚡️by Gautam Sharmahttps://gsharma.devRedis gRPC ⚡️ is a client library that emulates Redis-like features by leveraging gRPC communication. It provides a lightweight and efficient way to interact with a Redis-like server implemented using gRPC, offering developers a fast and seamless experience.FeaturesEmulates Redis-like functionalityUtilizes gRPC for communicationWritten in Python for ease of use and integrationLightweight and efficientInstallationTo install the redisgrpc Python client library, you can use pip:pipinstallredisgrpc==0.4UsageHere's an example demonstrating how to use the  redisgrpc client library:from__future__importprint_functionimportloggingfromredisgrpcimportredisgrpcasrgdefrun():# Initialize the Client with the server portc=rg.Client(50051)# Initialize the connectionc.init_connection()# Perform some Redis-like operationsforidxinrange(1,10):k=input("Set Key: ")v=input("Set Value: ")c.set(k,v)# Get the cached value backcached_val=c.get(k)print("Cached value of key{}is{}".format(k,cached_val))if__name__=="__main__":# Configure logginglogging.basicConfig()# Run the examplerun()AboutTheredis-grpc-serveris a library written purely in C++, utilizing gRPC as its communication layer. Despite its small size, this library is powerful and suitable for use in production environments. The aim is to provide developers with the best possible experience while maintaining extreme speed and efficiency.ContributingContributions to redisgrpc are welcome! Whether it's reporting bugs, suggesting new features, or contributing code, your input is valuable.LicenseThis project is licensed under the MIT License - see theLICENSEfile for details..
Package: redis-gt
Redis GTGlobal throttling with Redis.installationpip install redis-gtusageex) request with throttleimportredis_gtimportrequestsredis_gt.Defaults.redis_url='redis://127.0.0.1:6379'defget_members(**kwargs):throttle=redis_gt.Throttle('backend_api_call',20)returnthrottle.run(requests.get,'/api/members/',**kwargs)ex) same with asyncioimportasyncioimportredis_gtimportrequestsredis_gt.Defaults.redis_url='redis://127.0.0.1:6379'asyncdefget_members(**kwargs):def_get():returnrequests.get('/api/members/',**kwargs)loop=asyncio.get_event_loop()throttle=redis_gt.AsyncThrottle('backend_api_call',20)returnawaitthrottle.run(loop.run_in_executer(_get))throttlingimportredis_gtimporttimefromthreadingimportThreadredis_gt.Defaults.redis_url='redis://127.0.0.1:6379'defdo_something():time.sleep(1.0)defdo_something_with_throttle():# max 10 parallelsthrottle=Throttle(r,'something',10)throttle.run(do_something)# 100 tasks of each 1sec.threads=[Thread(target=do_something_with_throttle)for_inrange(100)]fortinthreads:t.start()# takes about 10secs (100tasks/10para).fortinthreads:t.join()throttling with asyncioimportasynciofromredis_gtimportAsyncThrottleimportredisasyncdefdo_something():awaitasyncio.sleep(1.0)r=redis.StrictRedis.from_url('redis://127.0.0.1:6379')# max 10 parallelsthrottle=AsyncThrottle(r,'something',10)# 100 tasks of each 1sec.tasks=[throttle.run(do_something())for_inrange(100)]loop=asyncio.get_event_loop()# takes about 10secs (100tasks/10para).loop.run_until_complete(asyncio.wait(tasks))decoratorfromredis_gtimportThrottlefromredis_gt.decoratorsimportthrottleimportredisr=redis.StrictRedis.from_url('redis://127.0.0.1:6379')# for sync function@throttle('something',10,redis=r)defdo_something():time.sleep(1.0)# 100 tasks of each 1sec.threads=[Thread(target=do_something)for_inrange(100)]fortinthreads:t.start()# takes about 10secs (100tasks/10para).fortinthreads:t.join()# for async function@throttle('something',10,redis=r)asyncdefdo_something_async():awaitasyncio.sleep(1.0)# 100 tasks of each 1sec.tasks=[do_something_async()for_inrange(100)]loop=asyncio.get_event_loop()# takes about 10secs (100tasks/10para).loop.run_until_complete(asyncio.wait(tasks))
Package: redish
Version:0.0.1IntroductionBraindump:>>> from redish.client import Client
>>> x = Client()

# Key/Value
>>> x["foo"] = {"name": "George"}
>>> x["foo"]
{'name': 'George'}
>>> del(x["foo"])
>>> x["foo"]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "redish/client.py", line 52, in __getitem__
    raise KeyError(key)
KeyError: 'foo'

# Sets

>>> s = x.Set("myset")
>>> map(s.add, ["opera", "firefox", "ie", "safari"])
[True, True, True, True]
>>> "opera" in s
True
>>> s.remove("safari")
>>> "safari" in s
False
>>> list(s)
['opera', 'ie', 'firefox']
>>> s2 = x.Set("myset2")
>>> map(s2.add, ["opera", "firefox", "mosaic"])
[True, True, True]
>>> s.difference(s2)
set(['opera', 'firefox', 'mosaic'])

# Sorted Set

>>> z = x.SortedSet("myzset")
>>> z.add("foo", 0.9)
True
>>> z.add("bar", 0.1)
True
>>> z.add("baz", 0.3)
True
>>> z[0:3]
['bar', 'baz', 'foo']InstallationYou can installredisheither via the Python Package Index (PyPI)
or from source.To install usingpip,:$ pip install redishTo install usingeasy_install,:$ easy_install redishIf you have downloaded a source tarball you can install it
by doing the following,:$ python setup.py build
# python setup.py install # as rootExamples
Package: redis-hash
Simple python interface for redis hash typeInstallationpipinstallredisredis_hashUsageFirst you need to instantiate the redis client from theredispackage:>>fromredisimportStrictRedis>>redis_client=StrictRedis(host='localhost',port=6379,db=0)Then create your hash passing the client and the hash key:>>fromredis_hashimportRedisHash>>redis_hash=RedisHash(redis_client,'hash_name')Now your can handle your hash like adict:>>redis_hash['foo']='bar'>>len(redis_hash)1>>'foo'inredis_hashTrue>>>fork,vinredis_hash:...print(k,v)...foobar>>>redis_hash['foo']b'bar'>>>list(redis_hash)[(b'foo',b'bar')]>>delredis_hash['foo']>>len(redis_hash)0>>'foo'inredis_hashFalse
Package: redis-heartbeat-lock
Basic Redis locking mechanism, implemented as an asynchronous context manager. Allows the caller to hold a lock, with a specified heartbeat, while doing a chunk of work.Free software: MITDocumentation:https://redis-heartbeat-lock.readthedocs.io.SponsorWe useredis-heartbeat-lockforB2C customer lifecycle optimization at Faraday.FeaturesTODOCreditsThis package was created withCookiecutterand thebriggySmalls/cookiecutter-pypackageproject template.
Package: redisimp
RedisImpallows you to quickly and safely import data from other redis hostsinto a running redis instance or cluster.redisimp -s 127.0.0.1:6379 -d 127.0.0.1:6380The script will take all the keys from the source127.0.0.1:6379and copy
them into the destination127.0.0.1:6380.It also allows you to copy data stored in RDB files.redisimp -s ./dump.rdb -d 127.0.0.1:6380You can also copy only a subset of keys by using a regex pattern:redisimp -s 127.0.0.1:6379 -d 127.0.0.1:6380 --pattern '/^I\{[A-Za-z0-9_\-]+\}$/'Or a glob style pattern:redisimp -s 127.0.0.1:6379 -d 127.0.0.1:6380 --pattern 'I{*}'
Package: redis-index
Redis-index: Inverted Index using efficient Redis setRedis-index helps to delegate part of the work from database to cache.
It is useful for highload projects, with complex serach logic underneath the hood.IntroductionSuppose you have to implement a service that will fetch data for a given set of filters.GET /api/companies?region=US&currency=USD&search_ids=233,816,266,...Filters may require a significant costs for the database: each of them involves joining multiple tables. By writing a solution on raw SQL, we have a risk of stumbling into database performance.Such "heavy" queries can be precalculated, and put into redis SET.
We can intersect the resulting SETs with each other, thereby greatly simplifying our SQL.search_ids={233,816,266,...}us_companies_ids={266,112,643,...}usd_companies_ids={816,54,8395,...}filtered_ids=search_ids&us_companies_ids&usd_companies_ids# intersection..."SELECT * from companies whrere id in{filtered_ids}"But getting such precalculated SETS from Redis to Python memory could be another bottleneck:
filters can be really large, and we don't want to transfer a lot of data between servers.The solution is intersect these SETs directly in redis.
This is exactly what redis-index library does.InstallationUsepipto installredis-index.pipinstallredis-indexUsageDeclare your filters. They must inherit BaseFilter class.fromredis_indeximportBaseFilterclassRegionFilter(BaseFilter):defget_ids(self,region,**kwargs)->List[int]:"""get_ids should return a precalculated list of ints."""withpsycopg2.connect(...)asconn:withconn.cursor()ascursor:cursor.execute('SELECT id FROM companies WREHE region =%s',(region,))returncursor.fetchall()classCurrencyFilter(BaseFilter):defget_ids(self,currency,**kwargs):withpsycopg2.connect(...)asconn:withconn.cursor()ascursor:cursor.execute('SELECT id FROM companies WREHE currency =%s',(currency,))returncursor.fetchall()Initialize Filtering objectfromredis_indeximportRedisFilteringfromhot_redisimportHotClientredis_clent=HotClient(host="localhost",port=6379)filtering=RedisFiltering(redis_clent)Now you can usefilteringas a singleton in your project.
Simply callfilter()method with specific filters, and yoursearch_idscompany_ids=request.GET["company_ids"]# input listresult=filtering.filter(search_ids,[RegionFilter("US"),CurrencyFilter("USD")])The result will be a list, that contains only ids, that are both satisfying RegionFilter and CurrencyFilter.How to warm the cache?You can warm up the cache in various ways, for example, using the cron command*/5  *   *   *   *   python warm_filtersInside such a command, you can use specific methodwarm_filtersresult=filtering.filter(search_ids,[RegionFilter("US"),CurrencyFilter("USD")])Or directly RedisIndex classfor_filterin[RegionFilter("US"),CurrencyFilter("USD")]:filter_index=RedisIndex(_filter,redis_client)filter_index.warm()Statsd integrationRedis-index optionally supports statsd-integration.Code of ConductEveryone interacting in the project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow thePyPA Code of Conduct.History[0.1.11] - 2019-11-08AddedAdded code for initial release
Package: redis-ipc
Redis IPCA lightweight multiple producer and single consumer IPC server
that uses redis pubsub as a brokerCreates a redis ipc server that listens on a single pub/sub channel
and allows you to communicate between multiple processesSubclass the IPC class and add your handlers as methods
like this (handlers must start withhandle_as their name)asyncdefhandle_channel_update(self,data):returndataor useIPC.add_handlerto add the handler after the
class has been instantiatedand whenever a process callsIPC.get, all the clients connected to
that channel will try to handle the request and whichever one finishes
first, will be returned by the functionthe handler must either return a dict orNoneNoneis treated as an implicit reason that the current
process doesn't matches the requests' target processChangelogVersion 0.2.1Bug FixesFixes a race condition where Future.set_result would raise InvalidStateError if another producer set a result alreadyAddedChangelog to pypi long descriptionVersion 0.2.0AddedAddsIPC.on_errorhandler for when a handler errors out. Takes error as first argument and message (the request data) as secondVersion 0.1.0Addedrequired_identity kwarg onIPC.getandIPC.publishadded more comments to examplesadded basic logging
Package: redisjobs
This is a Python client library for interacting with theJobsscheduler.Install with pip:pipinstallredisjobsimportredisjobsasjobs# if Redis is not running on your local machine,# specify Redis host and port, otherwise you# can initialize the object without argumentsboard=jobs.Board(host='127.0.0.1',port=6379)schedule={'minutes':5}board.put('my job','shell','echo "Hello world!"',schedule)printboard.get('my job')Take a look atjobs/__init__.pyfor more information.
Package: redis-json-dict
redis-json-dictUsage>>>importredis...redis_client=redis.Redis("localhost",6379)...d=RedisJSONDict(redis_client,prefix="my_dict")...d{}All user modifications, including mutation of nested lists or dicts, are
immediately synchronized to the Redis server.Design RequirementsThe dictionary implements Python'scollections.abc.MutableMappinginterface.All values stored in Redis are JSON-encoded, readily inspected with developer
eyeballs and possible to operate on from clients in languages other than
Python.Keys may be prefixed to reduce the likelihood of collisions when one Redis is
shared by multiple applications.No data is cached locally, so it is impossible to obtain a stale result.
However, the dictionary may becomposedwith other libraries, such ascachetools, to implement TTL caching for example.Top-level items liked['sample']may be accessed without synchronizing the
entire dictionary. Nested objects liked['sample']['color']are supported
(but may be less efficient).Mutating nested items, with operations liked['sample']['color'] = 'red'ord['sample']['positions'].append(3)triggers synchronization.
Package: redis-key-tagging
Redis Key TaggingDescriptionThis package provides key tagging and invalidation by tag features.
It provides theRedisKeyTaggingclass which extends theRedisclass fromredis-py, so it can be switched seamlessly.DocumentationOverriden method(s)set(): The new optional keyword argumenttags, which must be a list of string, can be used
to associate the key being set to each of those tags.New method(s)delete_keys_by_tag(): Delete all keys associated with the given tag.Tests$ py.test