Giter VIP home page Giter VIP logo

sider's Introduction

What is Sider?

Sider is a in-memory database with persistence option. This is a personal project I'm coding to practice Golang by doing.

What can Sider do?

  • Read/Add keys
  • Read List (complete or by range)
  • Push/Pop lists (LEFT and RIGHT)
  • Get length of a list
  • Get index of element in list
  • Expire lists/keys
  • Get length of list
  • Delete key
  • Delete list
  • Delete item from list by index
  • Delete item from list by its content
  • Backup lists and keys in JSON files.
  • Import last backup when starting Sider again

How to use Sider?

  1. Go to your project directory: cd ~/my-project
  2. Install dependency with go get -u github.com/jaavier/sider
  3. Import in your code import "github.com/jaavier/sider"

IMPORTANT UPDATE ๐Ÿ‘พ

I updated all functions to return a value and a error (if there's one). If you cloned this project before, please update your dependencies executing go get -u -d ./... in your project's folder

Persist data on disk

go sider.SaveData(customPath string) // execute as goroutine

Important: If you call sider.SaveData() without param, it will store data at /tmp

Import data from last session

go sider.ImportData(customPath string) // execute as goroutine

Important: If you call sider.ImportData() without param, it will find data at /tmp

Add Key

sider.Set(key, value string) (bool, error)

Read Key

sider.Get(key string) (string, error)

Push an item at left

sider.LPush(key string, value string) (bool, error)

Push an item at right

sider.RPush(key string, value string) (bool, error)

Get length of a list

sider.LLen(listName string) (int, error)

Get index of element in list

sider.IndexOf(listName string, element string) (int, error)

Replace element in list

sider.ReplaceList(listName string, index int, element string) (bool, error)

Read List

sider.GetList(listName string, start string, stop string) ([]string, error)

Parameters start and stop are optionals

Expire Key

sider.ExpireKey(key string, timestamp int64) (bool, error)

Expire List

sider.ExpireList(listName string, timestamp int64) (bool, error)

Pop list

Pop at right

sider.Pop(options ...string) (string, error)

Pop at left

sider.Pop(listName string, "left") (string, error)

Get list's length

func CountList(listName string) (int, error)

Delete key

func DeleteKey(key string) error

Delete list

func DeleteList(listName string) error

Delete item from list by its content

func DeleteItemByContent(listName string, item string) bool

Delete item from list by its index

func DeleteItemByIndex(listName string, index int) bool

If you don't know the index, you can find it with sider.IndexOf

TODO

  • Add function to reverse lists pic

sider's People

Contributors

jaavier avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

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.