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.

Files for redison, version 1.0a5
Filename, size File type Python version Upload date Hashes
Filename, size redison-1.0a5-py36-none-any.whl (2.7 kB) File type Wheel Python version py36 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page