Coder Social home page Coder Social logo

support for list data structure about summitdb HOT 3 CLOSED

komuw avatar komuw commented on June 13, 2024
support for list data structure

from summitdb.

Comments (3)

komuw avatar komuw commented on June 13, 2024

cc @tidwall

from summitdb.

tidwall avatar tidwall commented on June 13, 2024

Unfortunately I don't have any plans for adding list commands at this time.

One idea is to use the json commands inside a script.

For example and RPUSH could be:

> script load "sdb.call('set', KEYS[0], '[]', 'nx');sdb.call('jset', KEYS[0], '-1', ARGV[0]);return parseInt(sdb.call('jget', KEYS[0], '#'));"
"95e4005b8d5dff3778154ae39dd819a21c363d13"

Then you can use the script like:

> evalsha 95e4005b8d5dff3778154ae39dd819a21c363d13 1 mylist item1
1
> evalsha 95e4005b8d5dff3778154ae39dd819a21c363d13 1 mylist item2
2
> evalsha 95e4005b8d5dff3778154ae39dd819a21c363d13 1 mylist item3
3
> evalsha 95e4005b8d5dff3778154ae39dd819a21c363d13 1 mylist item4
4

For LPOP:

> script load "var res = sdb.call('jget', KEYS[0], '0');sdb.call('jdel', KEYS[0], '0');return res;"
"e3f15d9503ca033132d0e83b35ec3afcf28ef922"
> evalsha e3f15d9503ca033132d0e83b35ec3afcf28ef922 1 mylist
"item1"
> evalsha e3f15d9503ca033132d0e83b35ec3afcf28ef922 1 mylist
"item2"
> evalsha e3f15d9503ca033132d0e83b35ec3afcf28ef922 1 mylist
"item3"
> evalsha e3f15d9503ca033132d0e83b35ec3afcf28ef922 1 mylist
"item4"
> evalsha e3f15d9503ca033132d0e83b35ec3afcf28ef922 1 mylist
(nil)

The underlying data is just a json array. So you can get the entire list with a GET:

> evalsha 95e4005b8d5dff3778154ae39dd819a21c363d13 1 mylist item1
1
> evalsha 95e4005b8d5dff3778154ae39dd819a21c363d13 1 mylist item2
2
> GET mylist
"[\"item1\",\"item2\"]"

from summitdb.

komuw avatar komuw commented on June 13, 2024

thanks

from summitdb.

Related Issues (20)

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.