# How to use LruRedux cache in ruby filter

**URL:** https://discuss.elastic.co/t/how-to-use-lruredux-cache-in-ruby-filter/347893
**Category:** Elasticsearch
**Created:** [November 24, 2023, 2:44am UTC](https://discuss.elastic.co/t/how-to-use-lruredux-cache-in-ruby-filter/347893 "2023-11-24T02:44:03Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Chen\_Wei](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chen_wei/32/127587_2.png) [@Chen\_Wei](https://discuss.elastic.co/u/Chen_Wei)
#### Post date: [November 24, 2023, 2:44am UTC](https://discuss.elastic.co/t/how-to-use-lruredux-cache-in-ruby-filter/347893/1 "2023-11-24T02:44:03Z")

</div>

Somehow we have some logs having duplicated events, we want to dedup the events using fingerprint and LRU cache in the logstash pipeline, So I write a ruby file

```auto
require "lru_redux"

def register(params)
    limit = params["size"]
    @processedEvents = LruRedux::TTL::ThreadSafeCache.new(limit, 3600 )
end

def filter(event)
	return [event]
end

```

When i try to load the script and test, logstash report :  
he given configuration is invalid. Reason: Unable to configure plugins: (ScriptError) Error during load of '/Users/i337803/Workspaces/mcap/email-loganalyzer/email-loganalyzer-logstash/src/main/logstash/scripts/dedup.rb': #\<NoMethodError: undefined method `\<' for nil:NilClass\>

I don't see the operator '\<' in my file, What does this error complain about, I have no idea?

BTW, I see the Lru is already installed in the official Logstash package.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [December 22, 2023, 2:44am UTC](https://discuss.elastic.co/t/how-to-use-lruredux-cache-in-ruby-filter/347893/2 "2023-12-22T02:44:39Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
