NAME
Plack::Middleware::Throttle::Lite::Backend::Redis - Redis-driven storage
backend for Throttle-Lite
VERSION
version 0.02
DESCRIPTION
This is implemetation of the storage backend for
Plack::Middleware::Throttle::Lite. It uses redis-server to hold
throttling data, automatically sets expiration time for stored keys to
save memory consumption.
SYNOPSYS
# inside your app.psgi
enable 'Throttle::Lite',
backend => [
'Redis' => {
instance => 'redis.example.com:6379',
database => 1,
password => 'VaspUtnuNeQuiHesGapbootsewWeonJadacVebEe'
}
];
OPTIONS
This storage backend must be configured in order to use. All options
should be passed as a hash reference. The following options are
available to tune it for your needs.
instance
A string consist of a hostname (or an IP address) and port number
(delimited with a colon) or unix socket path of the redis-server
instance to connect to. Not required. Default value is 127.0.0.1:6379.
Some usage examples
# tcp/ip redis-servers
instance => ''; # treats as '127.0.0.1:6379'
instance => 'TCP:example.com:11230'; # ..as 'example.com:11230'
instance => 'tcp:redis.example.org'; # ..as 'redis.example.org:6379'
instance => 'redis-db.example.com'; # ..as 'redis-db.example.com:6379'
instance => 'tcp:127.0.0.1'; # ..as '127.0.0.1:6379'
instance => 'tcp:10.90.90.90:5000'; # ..as '10.90.90.90:5000'
instance => '192.168.100.230'; # ..as '192.168.100.230:6379'
instance => 'bogus:0' # ..as 'bogus:6379' (allowed > 0 and < 65536)
instance => 'Inet:172.16.5.4:65000'; # ..as '172.16.5.4:65000'
instance => 'bar:-100'; # ..as 'bar:6379' (allowed > 0 and < 65536)
instance => 'baz:70000'; # ..as 'baz:6379' (allowed > 0 and < 65536) and so on..
# unix sockets might be passed like this
instance => 'Unix:/var/foo/Redis.sock'; # this socket path '/var/foo/Redis.sock'
instance => '/bar/tmp/redis/sock'; # ..as '/bar/tmp/redis/sock',
instance => 'unix:/var/foo/redis.sock'; # ..as '/var/foo/redis.sock',
database
A redis-server database number to store throttling data. Not obligatory
option. If this one omitted then value 0 will be assigned.
password
Password string for redis-server's AUTH command to processing any other
commands. Optional. Check the redis-server manual for directive
*requirepass* if you would to use redis internal authentication.
reconnect
A time (in seconds) to re-establish connection to the redis-server
before an exception will be raised. Not required. Default value is 10
sec.
every
Interval (in milliseconds) after which will be an attempt to
re-establish lost connection to the redis-server. Not required. Default
value is 100 ms.
debug
Enables debug information to STDERR, including all interactions with the
redis-server. Not required. Default value is 0 (disabled).
METHODS
redis
Returns a redis connection handle.
rdb
A redis database number to store data.
init
See "ABSTRACT METHODS" in
Plack::Middleware::Throttle::Lite::Backend::Abstract
reqs_done
See "ABSTRACT METHODS" in
Plack::Middleware::Throttle::Lite::Backend::Abstract
increment
See "ABSTRACT METHODS" in
Plack::Middleware::Throttle::Lite::Backend::Abstract
BUGS
Please report any bugs or feature requests through the web interface at
<https://github.com/Wu-Wu/Plack-Middleware-Throttle-Lite-Backend-Redis/i
ssues>
SEE ALSO
Redis
Plack::Middleware::Throttle::Lite
Plack::Middleware::Throttle::Lite::Backend::Abstract
AUTHOR
Anton Gerasimov <chim@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Anton Gerasimov.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.