Metadata-Version: 2.4
Name: cloud-python-vars
Version: 0.1.1
Summary: To manage and create raw Python variables on cloud servers.
Author-email: ThatOnePythonDev <khakhang2h5e@gmail.com>
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: upstash-redis
Dynamic: license-file

## Introduction

A Python module for managing Cloud Variables.

## IMPORTANT NOTES

Since this module is built upon the package upstash-redis, you **MUST** visit the website right [here](https://console.upstash.com/redis) to create tokens and the link that are **nessecary** for the following examples.

## Examples:

### Example 1 for the `CloudVar` class.

```python
import cloud_variables as cv


cloudvar = cv.CloudVar("https://apparent-gopher-******.upstash.io", "******") # Use the actual values here.

# Basic assignment
cloudvar["string"] = "Hello, World!"

# Retrieving values
print(cloudvar["string"]) # 'Hello, World!'

# Advanced mutable objects
cloudvar["list"] = [1, 2, 3]
cloudvar["list"].append(4)

print(cloudvar["list"]) # [1, 2, 3, 4]

# Deleting and popping items
cloudvar["key1"] = "value1"
cloudvar["key2"] = "value2"

del cloudvar["key1"] # Deleting keys.
value = cloudvar.pop("key2") # Popping keys
print(value) # 'value2'

# Some more methods

# Retrieving Python key-value pairs as dictionaries
print(cloudvar.items()) # {'string': 'Hello, World!', 'list': [1, 2, 3, 4]}

# Clearing everything
cloudvar.clear()
print(cloudvar.items()) # {}
```

### Example 2 for the class `AsyncCloudVar`.

```python
import cloud_variables as cv
import asyncio


async def main(): # Use asynchronous functions for full functionality access.
    async_cloudvar = cv.AsyncCloudVar("https://apparent-gopher-******.upstash.io", "******") # Use your actual values again.
    async_cloudvar.start()

    # Basic assignment
    async_cloudvar["string"] = "Hello, World!"

    # Retrieving values
    print(async_cloudvar["string"]) # 'Hello, World!'

    # Advanced mutable objects
    async_cloudvar["list"] = [1, 2, 3]
    async_cloudvar["list"].append(4)

    print(async_cloudvar["list"]) # [1, 2, 3, 4]

    # Deleting and popping items
    async_cloudvar["key1"] = "value1"
    async_cloudvar["key2"] = "value2"

    del async_cloudvar["key1"] # Deleting keys.
    value = await async_cloudvar.pop("key2") # Popping keys
    print(value) # 'value2'

    # Some more methods

    # Retrieving Python key-value pairs as dictionaries
    print(await async_cloudvar.items()) # {'string': 'Hello, World!', 'list': [1, 2, 3, 4]}

    # Clearing everything
    await async_cloudvar.clear()
    print(await async_cloudvar.items()) # {}

asyncio.run(main())
```

## Installation

You can easily install the module by typing the command:

```bash
pip install cloud-python-vars
```
