semvec/pypi-packages huggingface dataset:
pyredpack 0.2.9
Serialize any python datatypes and does redis actions using redis-py
License: MIT
Requires Python: >=3.8

# PyRedPack

* Serialize any python datatypes and executes redis commands using redis-py
* When loading, it auutomatically converts serialized data into original data types

## Getting Started

### Install via pypi

`pip install PyRedPack`

### Instantiate

```python
from pyredpack import Redis
r = Redis(host='localhost', port=6379)
```

## Supporting Data Types

* Built-in

   * string
   * number(int, float)
   * dictionary
   * list
   * tuple
   * etc (all other python built-in types)

* Module Classes

   * pandas
   * numpy

## Supporting Redis Commands

### PyRedPack Supports

* Basic Functions

   * KEYS
   * RANDOMKEY
   * TYPE
   * SET
   * GET

* Hash Functions

   * HKEYS
   * HSET
   * HMSET
   * HGET
   * HMGET
   * HGETALL
   * HVALS

* Set Functions

   * SADD
   * SREM
   * SMEMBERS
   * SPOP
   * SDIFF
   * SCARD (Default)
   * SRANDMEMBER

* List Functions

   * LPUSH
   * RPUSH
   * LPUSHX
   * RPUSHX
   * LRANGE
   * LPOP
   * RPOP
   * LINDEX

* List Extra Functions

   * ZLIB COMPRESS SET
   * ZLIB COMPRESS GET

## Examples

### String

* Originally redis stores string into bytes.

```python
s = "This is a String. \n스트링입니다."
print(s)

 r.set('s', s)   
 r.get('s')   
type(r.get('s'))
```

### Numbers

```python
mapping = {
        'a': 29,
        'b': 0.5335113,
        'c': np.float64(0.243623466363223),}   

r.hmset('nums', mapping)   
r.hmget('nums', *mapping.keys())   
list(mapping.values()) == r.hmget('nums', *mapping.keys())
```

### Nested Dictionaries and Lists

```python
l = [1,2,3]
d = {'a': 1, 'b': 2, 'c': 3}   

r.hmset('list and dictionary', {'list': l, 'dict': d})   

r.hgetall("list and dictionary")
{'list': [1, 2, 3], 'dict': {'a': 1, 'b': 2, 'c': 3}}

type(r.hgetall("list and dictionary")['list'])

type(r.hgetall("list and dictionary")['dict'])

```

### Pandas DataFrame

```python
df =  pd.DataFrame([[1,2,3,'235', '@$$#@'], 
                       ['a', 'b', 'c', 'd', 'e']])
print(df)
r.set('df', df)   
r.get('df')

type(r.get('df'))
```

### Numpy Array

```sh
```python
arr = np.random.rand(10).reshape(5, 2)
print(arr)

r.set('a', arr)   
r.get('a')   

type(r.get('a'))
```
```

### Compress data with Python Zlib package

```sh
```python
df =  pd.DataFrame([[1,2,3,'235', '@$$#@'], 
                       ['a', 'b', 'c', 'd', 'e']])
print(df)
r.cset('df', df)   
r.cget('df')

type(r.cget('df'))
```
```

# Author

`PyRedPack` is developed and maintained by Amir taherkhani (amirtaherkhani@outlook.com).  
It can be found here: https://github.com/amirtaherkhani/PyRedPack

Special thanks to:

* Andy McCurdy, the author of redis-py.