Class: Gitlab::AnonymousSession

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/anonymous_session.rb

Instance Method Summary collapse

Constructor Details

#initialize(remote_ip) ⇒ AnonymousSession

Returns a new instance of AnonymousSession.


5
6
7
# File 'lib/gitlab/anonymous_session.rb', line 5

def initialize(remote_ip)
  @remote_ip = remote_ip
end

Instance Method Details

#cleanup_session_per_ip_countObject


24
25
26
27
28
# File 'lib/gitlab/anonymous_session.rb', line 24

def cleanup_session_per_ip_count
  Gitlab::Redis::SharedState.with do |redis|
    redis.del(session_lookup_name)
  end
end

#count_session_ipObject


9
10
11
12
13
14
15
16
# File 'lib/gitlab/anonymous_session.rb', line 9

def count_session_ip
  Gitlab::Redis::SharedState.with do |redis|
    redis.pipelined do
      redis.incr(session_lookup_name)
      redis.expire(session_lookup_name, 24.hours)
    end
  end
end

#session_countObject


18
19
20
21
22
# File 'lib/gitlab/anonymous_session.rb', line 18

def session_count
  Gitlab::Redis::SharedState.with do |redis|
    redis.get(session_lookup_name).to_i
  end
end