This file is indexed.

/usr/share/backgroundrb/server/lib/bdrb_result_storage.rb is in libbackgroundrb-ruby1.8 1.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
module BackgrounDRb
  class ResultStorage
    attr_accessor :cache,:worker_name,:worker_key,:storage_type
    def initialize(worker_name,worker_key,storage_type = nil)
      @worker_name = worker_name
      @worker_key = worker_key
      @mutex = Mutex.new
      @storage_type = storage_type
      @cache = (@storage_type == 'memcache') ? memcache_instance : {}
    end

    # Initialize Memcache for result or object caching
    def memcache_instance
      require 'memcache'
      memcache_options = {
        :c_threshold => 10_000,
        :compression => true,
        :debug => false,
        :namespace => 'backgroundrb_result_hash',
        :readonly => false,
        :urlencode => false
      }
      t_cache = MemCache.new(memcache_options)
      t_cache.servers = BDRB_CONFIG[:memcache].split(',')
      t_cache
    end

    # generate key based on worker_name and worker_key
    # for local cache, there is no need of unique key
    def gen_key key
      if storage_type == 'memcache'
        key = [worker_name,worker_key,key].compact.join('_')
        key
      else
        key
      end
    end

    # fetch object from cache
    def [] key
      @mutex.synchronize { @cache[gen_key(key)] }
    end

    def []= key,value
      @mutex.synchronize { @cache[gen_key(key)] = value }
    end

    def delete key
      @mutex.synchronize { @cache.delete(gen_key(key)) }
    end

    def shift key
      val = nil
      @mutex.synchronize do
        val = @cache[key]
        @cache.delete(key)
      end
      return val
    end
  end
end