GithubHelp home page GithubHelp logo

ziogaschr / bottle-memcache-decorator Goto Github PK

View Code? Open in Web Editor NEW
2.0 4.0 2.0 464 KB

Adds a memcache decorator in your Bottle application. It automatically stores the route result to memcache for routes where the bottle-memcache plugin is enabled.

License: MIT License

Python 100.00%

bottle-memcache-decorator's Introduction

bottle-memcache-decorator Build Status

This bottle-memcache-decorator plugin adds a memcache decorator in your Bottle application. It automatically stores the route result to memcache for routes where the bottle-memcache plugin is enabled.

Required

The bottle-extras and bottle_memcache plugins are required to be installed before this plugin.

Installation

Install with one of the following commands::

$ pip install bottle-memcache-decorator
$ easy_install bottle-memcache-decorator

or download the latest version from github::

$ git clone git://github.com/ziogaschr/bottle-memcache-decorator.git
$ cd bottle-memcache-decorator
$ python setup.py install

Usage

import bottle
from bottle.ext import memcache
from bottle_memcache_decorator import MemcacheDecoratorPlugin

app = bottle.Bottle()

keyword = 'mc'

# install memcache plugin
memcache_plugin = memcache.MemcachePlugin(keyword=keyword)
app.install(memcache_plugin)

# install the memcache decorator
memcache_decorator_plugin = MemcacheDecoratorPlugin(
                        memcache_keyword=keyword,
                        memcache_expire_time='mc_expire_time',
                        memcache_compress_level_keyword='mc_compress_level')
app.install(memcache_decorator_plugin)

# for example in this route we will set the expire time = 3600 sec
# and compression level = 3
@app.get('/:name', mc_expire_time=3600, mc_dec_compress_level=3)
def show(name, mc):
    # your code here

    return result

if __name__ == '__main__':
    run(app, host='0.0.0.0', port=8080, debug=True)

Configuration

MemcacheDecoratorPlugin(
    memcache_keyword='mc',
    memcache_expire_time='mc_expire_time',
    memcache_compress_level_keyword='mc_compress_level')

memcache_keyword: is the keyword set/used for the memcache plugin

memcache_expire_time: defines the router argument responsible for setting the memcache expire time

memcache_compress_level_keyword: defines the router argument responsible for setting the memcache compression level

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.