Skip to main content

Shared memory object with redis and json files.

Project description

Redison : Redis + Json : Shared objects in memory using redis and json files

Getting Started

numpy

from redison import RedisObject
import numpy as np

array = np.random.rand(10)  # Set the object in python stack
print(array) # Retrieve the object from the stack
array = RedisObject(array)  # Set the object in redis
print(array.get())  # Retrieve the object from the redis database

multiproc

Processus 1

from redison import RedisObject
import numpy as np

while True:
    # Push array1
    RedisObject(id="array1", data=np.random.rand(10))

    # Pull array2
    array2 = RedisObject(id="array2")

    # Wait for array1 to be set in redis by proc2
    print(array2.get(blocking=True)) 

Processus 2

from redison import RedisObject
import numpy as np

while True:
    # Push array2
    RedisObject(id="array2", data=np.random.rand(10))

    # Pull array1
    array1 = RedisObject(id="array1")

    # Wait for array1 to be set in redis by proc1
    print(array1.get(blocking=True)) 

multiproc remote

Processus 1

from redison import RedisObject
import numpy as np

while True:
    # Create array2
    array1 = np.random.rand(10)

    # Push array2 
    RedisObject(id="array1",
                data=array1,
                host="10.1.0.2")

    # Pull array1
    array2 = RedisObject(id="array2", 
                         host="10.2.0.2")

    # Wait for array1 to be set on the remote machine 2
    print(array2.get(blocking=True)) 

Processus 2

from redison import RedisObject
import numpy as np

while True:
    # Create array2
    array2 = np.random.rand(10)

    # Push array2 
    RedisObject(id="array2",
                data=array2,
                host="10.2.0.2")

    # Pull array1
    array1 = RedisObject(id="array1", 
                         host="10.1.0.2")

    # Wait for array1 to be set on the remote machine 1
    print(array1.get(blocking=True)) 

Contributions

Email me at j.cadic@9dw-lab.com for any questions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

redison-1.0a5-py36-none-any.whl (2.7 kB view hashes)

Uploaded Python 3.6

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page