<commit_before>shared_examples 'strings' do
  it 'should append a value to key' do
    subject.set('key1', 'Hello')
    subject.append('key1', ' World')

    subject.get('key1').should eq('Hello World')
  end

  it 'should decrement the integer value of a key by one' do
    subject.set('counter', '1')
    subject.decr('counter')

    subject.get('counter').should eq('0')
  end

  it 'should decrement the integer value of a key by the given number' do
    subject.set('counter', '10')
    subject.decrby('counter', '5')

    subject.get('counter').should eq('5')
  end

  it 'should get the value of a key' do
    subject.get('key2').should be_nil
  end

  it 'should returns the bit value at offset in the string value stored at key' do
    subject.set('key1', 'a')

    subject.getbit('key1', 1).should eq(1)
    subject.getbit('key1', 2).should eq(1)
    subject.getbit('key1', 3).should eq(0)
    subject.getbit('key1', 4).should eq(0)
    subject.getbit('key1', 5).should eq(0)
    subject.getbit('key1', 6).should eq(0)
    subject.getbit('key1', 7).should eq(1)
  end

  it 'should allow direct bit manipulation even if the string is not set' do
    subject.setbit('key1', 10, 1)
    subject.getbit('key1', 10).should eq(1)
  end

  it 'should get a substring of the string stored at a key' do
    subject.set('key1', 'This a message')

    subject.getrange('key1', 0, 3).should eq('This')
    subject.substr('key1', 0, 3).should eq('This')
  end

  it 'should set the string value of a key and return its old value' do
    subject.set('key1','value1')

    subject.getset('key1', 'value2').should eq('value1')
    subject.get('key1').should eq('value2')
  end

  it 'should return nil for #getset if the key does not exist when setting' do
    subject.getset('key1', 'value1').should be_nil
    subject.get('key1').should eq('value1')
  end

  it 'should increment the integer value of a key by one' do
    subject.set('counter', '1')
    subject.incr('counter').should eq(2)

    subject.get('counter').should eq('2')
  end

  it 'should not change the expire value of the key during incr' do
    subject.set('counter', '1')
    subject.expire('counter', 600).should be_true

    expect {
      subject.incr('counter').should eq(2)
    }.not_to change { subject.ttl('counter') }
  end

  it 'should decrement the integer value of a key by one' do
    subject.set('counter', '1')
    subject.decr('counter').should eq(0)

    subject.get('counter').should eq('0')
  end

  it 'should not change the expire value of the key during decr' do
    subject.set('counter', '2')
    subject.expire('counter', 600).should be_true

     expect {
      subject.decr('counter').should eq(1)
    }.not_to change { subject.ttl('counter') }
  end

  it 'should increment the integer value of a key by the given number' do
    subject.set('counter', '10')
    subject.incrby('counter', '5').should eq(15)
    subject.incrby('counter', 2).should eq(17)
    subject.get('counter').should eq('17')
  end

  it 'should not change the expire value of the key during incrby' do
    subject.set('counter', '1')
    subject.expire('counter', 600).should be_true

    expect {
      subject.incrby('counter', '5').should eq(6)
    }.not_to change { subject.ttl('counter') }
  end

  it 'should decrement the integer value of a key by the given number' do
    subject.set('counter', '10')
    subject.decrby('counter', '5').should eq(5)
    subject.decrby('counter', 2).should eq(3)
    subject.get('counter').should eq('3')
  end

  it 'should not change the expire value of the key during decrby' do
    subject.set('counter', '8')
    subject.expire('counter', 600).should be_true

    expect {
      subject.decrby('counter', '3').should eq(5)
    }.not_to change { subject.ttl('counter') }<commit_msg>Take into account time differences.<commit_after>shared_examples 'strings' do
  it 'should append a value to key' do
    subject.set('key1', 'Hello')
    subject.append('key1', ' World')

    subject.get('key1').should eq('Hello World')
  end

  it 'should decrement the integer value of a key by one' do
    subject.set('counter', '1')
    subject.decr('counter')

    subject.get('counter').should eq('0')
  end

  it 'should decrement the integer value of a key by the given number' do
    subject.set('counter', '10')
    subject.decrby('counter', '5')

    subject.get('counter').should eq('5')
  end

  it 'should get the value of a key' do
    subject.get('key2').should be_nil
  end

  it 'should returns the bit value at offset in the string value stored at key' do
    subject.set('key1', 'a')

    subject.getbit('key1', 1).should eq(1)
    subject.getbit('key1', 2).should eq(1)
    subject.getbit('key1', 3).should eq(0)
    subject.getbit('key1', 4).should eq(0)
    subject.getbit('key1', 5).should eq(0)
    subject.getbit('key1', 6).should eq(0)
    subject.getbit('key1', 7).should eq(1)
  end

  it 'should allow direct bit manipulation even if the string is not set' do
    subject.setbit('key1', 10, 1)
    subject.getbit('key1', 10).should eq(1)
  end

  it 'should get a substring of the string stored at a key' do
    subject.set('key1', 'This a message')

    subject.getrange('key1', 0, 3).should eq('This')
    subject.substr('key1', 0, 3).should eq('This')
  end

  it 'should set the string value of a key and return its old value' do
    subject.set('key1','value1')

    subject.getset('key1', 'value2').should eq('value1')
    subject.get('key1').should eq('value2')
  end

  it 'should return nil for #getset if the key does not exist when setting' do
    subject.getset('key1', 'value1').should be_nil
    subject.get('key1').should eq('value1')
  end

  it 'should increment the integer value of a key by one' do
    subject.set('counter', '1')
    subject.incr('counter').should eq(2)

    subject.get('counter').should eq('2')
  end

  it 'should not change the expire value of the key during incr' do
    subject.set('counter', '1')
    subject.expire('counter', 600).should be_true

    subject.ttl('counter').should eq(600)
    subject.incr('counter').should eq(2)
    subject.ttl('counter').should be_within(30).of(600)
  end

  it 'should decrement the integer value of a key by one' do
    subject.set('counter', '1')
    subject.decr('counter').should eq(0)

    subject.get('counter').should eq('0')
  end

  it 'should not change the expire value of the key during decr' do
    subject.set('counter', '2')
    subject.expire('counter', 600).should be_true

    subject.ttl('counter').should eq(600)
    subject.decr('counter').should eq(1)
    subject.ttl('counter').should be_within(30).of(600)
  end

  it 'should increment the integer value of a key by the given number' do
    subject.set('counter', '10')
    subject.incrby('counter', '5').should eq(15)
    subject.incrby('counter', 2).should eq(17)
    subject.get('counter').should eq('17')
  end

  it 'should not change the expire value of the key during incrby' do
    subject.set('counter', '1')
    subject.expire('counter', 600).should be_true

    subject.ttl('counter').should eq(600)
    subject.incrby('counter', '5').should eq(6)
    subject.ttl('counter').should be_within(30).of(600)
  end

  it 'should decrement the integer value of a key by the given number' do
    subject.set('counter', '10')
    subject.decrby('counter', '5').should eq(5)
    subject.decrby('counter', 2).should eq(3)
    subject.get('counter').should eq('3')
  end

  it 'should not change the expire value of the key during decrby' do
    subject.set('counter', '8')
    subject.expire('counter', 600).should be_true

    subject.ttl('counter').should eq(600)
    subject.decrby('counter', '3').should eq(5)
    subject.ttl('counter').should be_within(30).of(600)
{'fraction_non_alphanumeric': 0.14831547695882277, 'fraction_numerical': 0.030721569639860592, 'mean_word_length': 3.56570418385386, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1515938', 'n_tokens_mistral': 2671, 'n_tokens_neox': 2502, 'n_words': 782}