Giter VIP home page Giter VIP logo

Comments (2)

pablito-dev avatar pablito-dev commented on September 26, 2024

I rewrote Kotlin to Java example for convenience:

public String method(final String key) {
        try (final Jedis connection = jedisPool.getResource()) {
            connection.hsetnx(key, HASH_CONST, UUID.randomUUID().toString());
            connection.expire(key, EXPIRE_CONST);
            return connection.hget(key, HASH_CONST)
        }
    }

from jedis-mock.

Savrov avatar Savrov commented on September 26, 2024

The same issue here.
My example code:

fun saveHMap(id: String, properties: HashMap<String, String>, ttl: Long? = null): Result<String> {
        if (properties.isNotEmpty()) {
            try {
                val result = jedis.hmset(id, properties)
                if (jedis.exists(id)) {
                    if (ttl != null && ttl > 0) {
                        return if (jedis.pexpire(id, ttl) == 1L) {
                            Result.Success("The timeout was set")
                        } else {
                            Result.Failure(NoSuchElementException("Key does not exist"))
                        }
                    }
                    return Result.Success(result)
                } else {
                    return Result.Failure(NoSuchElementException("Key was not found"))
                }
            } catch (ex: Exception) {
                return Result.Failure(ex)
            }
        } else {
            return Result.Failure(IllegalArgumentException("properties cant be empty"))
        }
    }

So I always end up with my own exception "Key does not exist" (code 0). Please note that I'm using pexpire function.

from jedis-mock.

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.