ruby-net-ldap icon indicating copy to clipboard operation
ruby-net-ldap copied to clipboard

Net::LDAP::Filter does not Implement Hash Method

Open Ajedi32 opened this issue 13 years ago • 4 comments

In my Ruby application, I am attempting to cache LDAP requests to improve performance. I want to cache the requests by filter, but Net::LDAP::Filter doesn't implement the hash method correctly, which messes up the caching solution that I am using:

irb(main):001:0> Net::LDAP::Filter.present("cn").hash == Net::LDAP::Filter.present("cn").hash
=> false

Some simple hash support for LDAP filters would be nice. For now I'll just use the string returned by the filter's .inspect method as the key for my cache instead.

Ajedi32 avatar Sep 07 '12 19:09 Ajedi32

@Ajedi32 that's a good suggestion. Would you be interested in creating a pull-request for this? It should be pretty straightforward, and the relevant hash components would be here https://github.com/ruby-ldap/ruby-net-ldap/blob/master/lib/net/ldap/filter.rb#L28-L35

jch avatar Oct 07 '14 19:10 jch

It's been over 2 years now so my interest in this feature has lessened somewhat, but I am still using Net::LDAP so if I run into this problem again I will certainly look into creating a pull request as you suggested.

Ajedi32 avatar Oct 08 '14 00:10 Ajedi32

@Ajedi32 what kind of caching scenario are you using? Are you caching between web requests? Are you caching in memcached? Are the search results being stored in memcached or in a local in-memory cache store?

mtodd avatar Oct 11 '14 18:10 mtodd

@mtodd Right now I'm not using any caching solution (aside from the built-in stuff Rails does automatically). Data in LDAP doesn't change very frequently for me, so my plan was to cache the results of specific queries in memory for the duration of the request, and perhaps even for several minutes after that.

Ajedi32 avatar Oct 11 '14 22:10 Ajedi32