Coder Social home page Coder Social logo

tair-opensource / tairstring Goto Github PK

View Code? Open in Web Editor NEW
110.0 110.0 17.0 294 KB

A redis module, similar to redis string, but you can set expire and version for the value. It also provides many very useful commands, such as cas/cad, etc.

License: Apache License 2.0

CMake 0.48% C 72.77% Tcl 26.02% Dockerfile 0.72%
cad cas module redis string

tairstring's Issues

关于CAD比较值和删除原子性问题

    RedisModuleCallReply *replay = RedisModule_Call(ctx, "GET", "s", argv[1]);
    switch (RedisModule_CallReplyType(replay)) {
        case REDISMODULE_REPLY_STRING:
            break;
        default:
            RedisModule_ReplyWithLongLong(ctx, 0);
            return REDISMODULE_OK;
    }

    const char *proto_ptr = RedisModule_CallReplyStringPtr(replay, &proto_len);
    const char *expect_ptr = RedisModule_StringPtrLen(argv[2], &expect_len);
    if (proto_len != expect_len || memcmp(expect_ptr, proto_ptr, proto_len) != 0) {
        RedisModule_ReplyWithLongLong(ctx, 0);
        return REDISMODULE_OK;
    }
}

RedisModule_DeleteKey(key);
RedisModule_Replicate(ctx, "DEL", "s", argv[1]);

可以看到,从比较值到删除是不能保证原子性的,这方面是怎么处理的使得CAD保证原子性的呢.
实在没看明白,希望解答,感谢感谢~

[NEW] exset command update version

Description of the feature

If VER and ABS flag exist at the same,
update the version directly to new version that special by abs for a key when version equivalent ver.

eg: exset k1 value ver 2 abs 5

when version = 2, update value and version to 5

[BUG] KEEPTTL option in EXSET can't be propagated to replica

To reproduce
In my test case, redis8001 is the replica of redis8000, as follows,

$ redis-cli -p 8000 role
1) "master"
2) (integer) 14
3) 1) 1) "127.0.0.1"
      2) "8001"
      3) "14"

Tairstring module was compiled with the main branch of the repo,

$ redis-cli -p 8000 module list
1) 1) "name"
   2) "exstrtype"
   3) "ver"
   4) (integer) 1

When I use EXSET with KEEPTTL option in master, it cannot work in the replica,

$ redis-cli -p 8000 exset k v1 ex 600
OK
$ redis-cli -p 8000 ttl k
(integer) 593
$ redis-cli -p 8001 ttl k
(integer) 590

# use keepttl
$ redis-cli -p 8000 exset k v2 keepttl
OK
$ redis-cli -p 8000 ttl k
(integer) 568
$ redis-cli -p 8001 ttl k
(integer) -1

We can see, ttl in the replica disappeared.

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.