@Test public void saveChannel() { final Channel channel = newChannel2(); assertThat(newRedisDataStore().saveChannel(channel), is(true)); }
@Override public boolean saveChannel(final Channel channel) { final Jedis jedis = jedisPool.getResource(); try { final String uaid = channel.getUAID(); final String chid = channel.getChannelId(); if (jedis.sismember(uaidLookupKey(uaid), chid)) { return false; } final String endpointToken = channel.getEndpointToken(); final Transaction tx = jedis.multi(); tx.set(endpointToken, Long.toString(channel.getVersion())); tx.set(tokenLookupKey(endpointToken), chid); tx.hmset(chidLookupKey(chid), mapOf(endpointToken, uaid)); tx.sadd(uaidLookupKey(uaid), chid); tx.exec(); return true; } finally { jedisPool.returnResource(jedis); } }
RedisDataStore implements DataStore { @Override public boolean saveChannel(final Channel channel) { final Jedis jedis = jedisPool.getResource(); try { final String uaid = channel.getUAID(); final String chid = channel.getChannelId(); if (jedis.sismember(uaidLookupKey(uaid), chid)) { return false; } final String endpointToken = channel.getEndpointToken(); final Transaction tx = jedis.multi(); tx.set(endpointToken, Long.toString(channel.getVersion())); tx.set(tokenLookupKey(endpointToken), chid); tx.hmset(chidLookupKey(chid), mapOf(endpointToken, uaid)); tx.sadd(uaidLookupKey(uaid), chid); tx.exec(); return true; } finally { jedisPool.returnResource(jedis); } } }
RedisDataStore implements DataStore { @Override public boolean saveChannel(final Channel channel) { final Jedis jedis = jedisPool.getResource(); try { final String uaid = channel.getUAID(); final String chid = channel.getChannelId(); if (jedis.sismember(uaidLookupKey(uaid), chid)) { return false; } final String endpointToken = channel.getEndpointToken(); final Transaction tx = jedis.multi(); tx.set(endpointToken, Long.toString(channel.getVersion())); tx.set(tokenLookupKey(endpointToken), chid); tx.hmset(chidLookupKey(chid), mapOf(endpointToken, uaid)); tx.sadd(uaidLookupKey(uaid), chid); tx.exec(); return true; } finally { jedisPool.returnResource(jedis); } } RedisDataStore(final String host, final int port); }
RedisDataStore implements DataStore { @Override public boolean saveChannel(final Channel channel) { final Jedis jedis = jedisPool.getResource(); try { final String uaid = channel.getUAID(); final String chid = channel.getChannelId(); if (jedis.sismember(uaidLookupKey(uaid), chid)) { return false; } final String endpointToken = channel.getEndpointToken(); final Transaction tx = jedis.multi(); tx.set(endpointToken, Long.toString(channel.getVersion())); tx.set(tokenLookupKey(endpointToken), chid); tx.hmset(chidLookupKey(chid), mapOf(endpointToken, uaid)); tx.sadd(uaidLookupKey(uaid), chid); tx.exec(); return true; } finally { jedisPool.returnResource(jedis); } } RedisDataStore(final String host, final int port); @Override void savePrivateKeySalt(final byte[] salt); @Override byte[] getPrivateKeySalt(); @Override boolean saveChannel(final Channel channel); @Override void removeChannels(final Set<String> channelIds); @Override Channel getChannel(final String channelId); @Override Set<String> getChannelIds(final String uaid); @Override void removeChannels(final String uaid); @Override String updateVersion(final String endpointToken, final long newVersion); @Override String saveUnacknowledged(final String channelId, final long version); @Override Set<Ack> getUnacknowledged(final String uaid); @Override Set<Ack> removeAcknowledged(final String uaid, final Set<Ack> acks); }
RedisDataStore implements DataStore { @Override public boolean saveChannel(final Channel channel) { final Jedis jedis = jedisPool.getResource(); try { final String uaid = channel.getUAID(); final String chid = channel.getChannelId(); if (jedis.sismember(uaidLookupKey(uaid), chid)) { return false; } final String endpointToken = channel.getEndpointToken(); final Transaction tx = jedis.multi(); tx.set(endpointToken, Long.toString(channel.getVersion())); tx.set(tokenLookupKey(endpointToken), chid); tx.hmset(chidLookupKey(chid), mapOf(endpointToken, uaid)); tx.sadd(uaidLookupKey(uaid), chid); tx.exec(); return true; } finally { jedisPool.returnResource(jedis); } } RedisDataStore(final String host, final int port); @Override void savePrivateKeySalt(final byte[] salt); @Override byte[] getPrivateKeySalt(); @Override boolean saveChannel(final Channel channel); @Override void removeChannels(final Set<String> channelIds); @Override Channel getChannel(final String channelId); @Override Set<String> getChannelIds(final String uaid); @Override void removeChannels(final String uaid); @Override String updateVersion(final String endpointToken, final long newVersion); @Override String saveUnacknowledged(final String channelId, final long version); @Override Set<Ack> getUnacknowledged(final String uaid); @Override Set<Ack> removeAcknowledged(final String uaid, final Set<Ack> acks);  }