Method: OpenC3::Store#trim_topic

Defined in:
lib/openc3/utilities/store_autoload.rb

#trim_topic(topic, minid, approximate = 'true', limit: 0) ⇒ Integer

Trims older entries of the redis stream if needed. > www.rubydoc.info/github/redis/redis-rb/Redis:xtrim

Examples:

Without options

store.trim_topic('MANGO__TOPIC', 1000)

With options

store.trim_topic('MANGO__TOPIC', 1000, approximate: 'true', limit: 0)

Parameters:

  • topic (String)

    the stream key

  • minid (Integer)

    mid id length of entries to trim

  • approximate (Boolean) (defaults to: 'true')

    whether to add '~` modifier of maxlen or not

  • limit (Boolean) (defaults to: 0)

    whether to add '~` modifier of maxlen or not

Returns:

  • (Integer)

    the number of entries actually deleted



224
225
226
227
228
# File 'lib/openc3/utilities/store_autoload.rb', line 224

def trim_topic(topic, minid, approximate = 'true', limit: 0)
  @redis_pool.with do |redis|
    return redis.xtrim_minid(topic, minid, approximate: approximate, limit: limit)
  end
end