Giter Site home page Giter Site logo

sandsnake's Introduction

Sandsnake

https://secure.travis-ci.org/numan/sandsnake.png?branch=master

Introduction

Sandsnake is a sorted index implemented in python and uses redis as a backend. It was originally implemented to be used as an indexing system for Sunspear.

Requirements

Required

Requirements should be handled by setuptools, but if they are not, you will need the following Python packages:

  • nydus
  • redis
  • dateutil

Optional

  • hiredis

sandsnake.create_sandsnake_backend

Creates an sandsnake object that allows to to store and retrieve indexes:

>>> from sandsnake import create_sandsnake_backend
>>>
>>> sandsnake = create_sandsnake_backend({
>>>     'backend': 'sandsnake.backends.redis.Redis',
>>>     'settings': {
>>>         'defaults': {
>>>             'host': 'localhost',
>>>             'port': 6379,
>>>             'db': 0,
>>>         },
>>>         'hosts': [{'db': 0}, {'db': 1}, {'host': 'redis.example.org'}]
>>>     },
>>> })

Internally, the Redis sandsnake backend uses nydus to distribute your indexes data over your cluster of redis instances.

There are two required arguements:

  • backend: full path to the backend class, which should extend sandsnake.backends.base.BaseSandsnakeBackend
  • settings: settings required to initialize the backend. For the Redis backend, this is a list of hosts in your redis cluster.

Example Usage

Redis

from sandsnake import create_sandsnake_backend
import datetime

sandsnake = create_sandsnake_backend({
    "backend": "sandsnake.backends.redis.Redis",
    "settings": {
        "hosts": [{"db": 5}]
    },
})

#add a value of "abc" to the ``index`` for an ``object``
sandsnake.add("user:1", "homefeed", "abc")
sandsnake.add("user:1", ["homefeed", "recogfeed"], "abc")

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.