Skip to content

Commit

Permalink
Merge pull request #110 from yahoo/update_windows_doc_info
Browse files Browse the repository at this point in the history
Update windows doc info
  • Loading branch information
dwighthubbard authored Jan 7, 2017
2 parents ba6e41a + 1dca6dc commit 82dfab0
Showing 1 changed file with 87 additions and 36 deletions.
123 changes: 87 additions & 36 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
redislite
Redislite
*********

.. image:: https://img.shields.io/travis/yahoo/redislite.svg
Expand All @@ -7,9 +7,6 @@ redislite
.. image:: https://img.shields.io/coveralls/yahoo/redislite.svg
:target: https://coveralls.io/r/yahoo/redislite

.. image:: https://img.shields.io/pypi/dm/redislite.svg
:target: https://pypi.python.org/pypi/redislite/

.. image:: https://img.shields.io/pypi/v/redislite.svg
:target: https://pypi.python.org/pypi/redislite/

Expand All @@ -19,8 +16,6 @@ redislite
.. image:: https://img.shields.io/pypi/l/redislite.svg
:target: https://pypi.python.org/pypi/redislite/

---------------------------------------------------------------------

.. image:: https://readthedocs.org/projects/redislite/badge/?version=latest
:target: http://redislite.readthedocs.org/en/latest/
:alt: Documentation Status
Expand All @@ -37,16 +32,22 @@ redislite

Description
===========
Self contained Python interface to the Redis key-value store.

It makes it possible to use Redis securely without the need to install and
configure a redis server.
Redislite is a self contained Python interface to the Redis key-value store.

It provides enhanced versions of the Redis-Py Python bindings for Redis. That provide the following added functionality:

* **Easy to use** - It provides a built in Redis server that is automatically installed, configured and managed when the Redis bindings are used.
* **Flexible** - Create a single server shared by multiple programs or multiple independent servers. All the servers provided by Redislite support all Redis functionality including advanced features such as replication and clustering.
* **Compatible** - It provides enhanced versions of the Redis-Py python Redis bindings as well as functions to patch them to allow most existing code that uses them to run with little or no modifications.
* **Secure** - It uses a secure default Redis configuraton that is only accessible by the creating user on the computer system it is run on.

Requirements
------------

The redislite module requires Python 2.7 or higher.


Installing on Linux
~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -77,7 +78,18 @@ running::

xcode-select --install

Installing on Microsoft Windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Redislite can be installed on newer releases of Windows 10 under the Bash on Ubuntu shell.

Install it using the instructions at https://msdn.microsoft.com/commandline/wsl/install_guide

Then start the bash shell and install the python-dev package as follows::

apt-get install python-dev
Installation
============

Expand All @@ -97,32 +109,26 @@ or from source:
Getting Started
===============

.. code-block:: python
>>> import redislite
>>> r = redislite.StrictRedis()
>>> r.set('foo', 'bar')
True
>>> r.get('foo')
'bar'
Usage
=====

redislite provides enhanced versions of the redis.Redis() and
redis.StrictRedis() classes that take the same arguments as the corresponding
redislite provides enhanced versions of the redis-py redis.Redis() and
redis.StrictRedis() classes that take the same arguments as the corresponding
redis classes and take one additional optional argument. Which is the
name of the Redis rdb file to use. If the argument is not provided it will
create a new one.
create set up a new redis server.

redislite also provides functions to MonkeyPatch the redis.Redis and
redis.StrictRedis classes to use redislite, so existing python code that uses
Redis can use the redislite version.

Example
=======
Examples
========

Here we open a Python shell and set a key in our embedded Redis db
Here are some examples of using the redislite module.

Setting a value
---------------

Here we open a Python shell and set a key in our embedded Redis db. Redislite will automatically start the Redis server when
the Redis() object is created and shut it down cleanly when the Python interpreter exits.

.. code-block:: python
Expand All @@ -134,9 +140,12 @@ Here we open a Python shell and set a key in our embedded Redis db
True
>>> redis_connection.get('key')
'value'
>>> quit()
Here we open the same Redis db and access the key we created during the last
run
Persistence
-----------
Now we open the same Redis db and access the key we created during the last run. Redislite will automatically start the
Redis server using the same configuration as last time, so the value that was set in the previous example is still available.

.. code-block:: python
Expand All @@ -146,8 +155,12 @@ run
['key']
>>> redis_connection.get('key')
'value'
>>> quit()
Compatibility
-------------

It's also possible to MonkeyPatch the normal Redis classes to allow modules
It's possible to MonkeyPatch the normal Redis classes to allow modules
that use Redis to use the redislite classes. Here we patch Redis and use the
redis_collections module.

Expand All @@ -161,17 +174,55 @@ redis_collections module.
>>> td.keys()
['foo']
Finally it's possible ot spin up multiple instances with different
configuration values for the Redis server. Here is an example that sets up 2
redis instances. One instance is configured to listen on port 8002, the
Running and using Multiple servers
----------------------------------

Redislite will start a new server if the redis rdb fileame isn't specified or is new. In this example we start 10 seperate redis servers and set the value of the key 'servernumber' to a different value in each server.

Then we access the value of 'servernumber' and print it.

>>> import redislite
>>> servers = {}
>>> for redis_server_number in range(10):
... servers[redis_server_number] = redislite.Redis()
... servers[redis_server_number].set('servernumber', redis_server_number)
...
True
True
True
True
True
True
True
True
True
True
>>> for redis_server in servers.values():
... redis_server.get('servernumber')
...
b'0'
b'1'
b'2'
b'3'
b'4'
b'5'
b'6'
b'7'
b'8'
b'9'

Multiple Servers with different configurations in the same script
-----------------------------------------------------------------

It's possible to spin up multiple instances with different
configuration settings for the Redis server. Here is an example that sets up 2
redis server instances. One instance is configured to listen on port 8002, the
second instance is a read-only slave of the first instance.


.. code-block:: python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import redislite
>>> master=redislite.Redis(serverconfig={'port': '8002'})
>>> slave=redislite.Redis(serverconfig={'slaveof': "127.0.0.1 8002"})
Expand Down

0 comments on commit 82dfab0

Please sign in to comment.