ruby-net-ldap
ruby-net-ldap copied to clipboard
Net::LDAP::Filter does not Implement Hash Method
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 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
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 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 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.