Skip to content
/ sponge Public

An elegant cache library for python 一个高性能优雅的缓存库

License

Notifications You must be signed in to change notification settings

IamBusy/sponge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status PyPI - Python Version PyPI - License Codecov branch

sponge

An elegant cache library for python

How to use

Install

pip install sponge

Usage

from sponge import CacheManager

# config cache manager
manager = CacheManager({
    'default': 'redis',
    'redis': {
        'host': 'localhost',
        'port': 3306,
        'db': 0
    },
    'memory': {},
    'sqlite': {
        'db': 'cache.db'
    }
})

# get cache instance
cache = manager.store('redis')

# set cache
cache.put('mykey', 'myvalue', 30) # 30 seconds
cache.get('mykey')                # myvalue

# remove cache
cache.forget('mykey')

# cache fover
cache.fover('mykey', 1)

# increase
cache.increase('mykey')     # the value will be 2

# decrease
cache.decrease('mykey', 2)  # the value will be -1


# clear all
cache.flush()

TODO

  • Support cache events
  • Support file driver
  • Support database driver
  • Added into awesome-python

About

An elegant cache library for python 一个高性能优雅的缓存库

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages