Skip to main content

A simple async redis cache module.

Project description

System Requirements

  • Python >= 3.7
  • moca_core
  • aioredis

Installation

pip install moca_async_redis_cache==1.0.1
or
pip install moca_async_redis_cache

Overview

English

This is a simple async redis cache module. Developed by el.ideal-ideas for Moca System.


日本語

これはel.ideal-ideasによって開発されたモカシステムのためのシンプルな非同期Redisキャッシュモジュールです。


简体中文

这是el.ideal-ideas为茉客系统开发的异步化Redis缓存模块模块。

Usage Example

# Instantiate the MocaAsyncRedisCache class.
# MocaAsyncRedisCacheのインスタント化。
# 创建MocaAsyncRedisCache的实例。
cache = MocaAsyncRedisCache()

# Initialize the connection pool.
# コネクションプールの初期化
# 初始化连接池。
cache.init_connection_pool(('127.0.0.1', 6379), 0)

# Set cache
# キャッシュを保存
# 保存缓存
cache.set('test_key', 'test_value', 60)

# Get cache
# キャッシュ取得
# 获取缓存
cache.get('test_key')
Main Methods
  • async def init_connection_pool(address: Union[Tuple[str, int], str], db: int, password: Optional[str] = None, ssl: Optional[SSLContext] = None, encoding: Optional[str] = None, minsize: int = 1, maxsize: int = 10, loop=None) -> Tuple[bool, str]:

    • creates a new connection pool
    • 新しいコネクションプールを作成します。
    • 新建一个连接池。
  • def set_connection_pool(pool: ConnectionsPool) -> None:

    • add a connection pool to this instance.
    • 既存コネクションプールを追加します。
    • 添加连接池。
  • def set_encoding(encoding: Optional[str]) -> None:

    • Set the encoding.
    • 文字コードを設定します。
    • 设定文字编码。
  • async def execute(command: str, args: Tuple) -> Tuple[bool, Any, str]:

    • This method can execute any redis command.
    • 任意のRedisコマンドを実行可能
    • 可执行任意的Redis命令。
  • async def set(key: str, value: int, expire: int = -1) -> Tuple[bool, str]:

    • Set a value
    • 値を設定します。
    • 保存一个值。
  • async def get(key: str, default: Optional[int] = None) -> Tuple[Optional[int], str]:

    • Get a value
    • 値を取得します。
    • 获取一个值。
  • async def clear(key: str) -> Tuple[bool, str]:

    • remove the value
    • 値を削除します。
    • 删除所选的值。
  • async def clear_db() -> Tuple[bool, str]:

    • Clear the database.
    • データベースをクリアします。
    • 清空数据库。

License

  • MIT License
Copyright 2020.1.17 <el.ideal-ideas: https://www.el-ideal-ideas.com>

Permission is hereby granted, free of charge, 
to any person obtaining a copy of this software 
and associated documentation files (the "Software"),
to deal in the Software without restriction, 
including without limitation the rights to use, copy, 
modify, merge, publish, distribute, sublicense, 
and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, 
subject to the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH 
THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Other Information

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 moca-async-redis-cache, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size moca_async_redis_cache-1.0.1-py3-none-any.whl (7.0 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size moca_async_redis_cache-1.0.1.tar.gz (5.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page