Sha256: 2a58b1ff088cb1eadac17fea43847c10d5d9e644049e9a24ba66c10522199d27

Contents?: true

Size: 1.54 KB

Versions: 105

Compression:

Stored size: 1.54 KB

Contents

##   RSence
 #   Copyright 2008 Riassence Inc.
 #   http://riassence.com/
 #
 #   You should have received a copy of the GNU General Public License along
 #   with this software package. If not, contact licensing@riassence.com
 ##


# @private Inner workings of Ticket
module TicketService
# @private Inner workings of Ticket
module Img
  
  # Removes image data and references. Image is removed with
  # its ID which is the same as its URI.
  def del_img( img_id, ses_id=false )
    if ses_id and @imgs[:ses_ids].has_key?( ses_id )
      @imgs[:ses_ids][ses_id].delete( img_id ) if @imgs[:ses_ids][ses_id].include?( img_id )
    end
    @imgs[:by_id].delete( img_id ) if @imgs[:by_id].has_key?( img_id )
  end
  
  # Extends expiration time of disposable files, essentially for keep-alive
  # requests. Image URI is used as an ID and extension is given as seconds.
  def push_keepalive( img_id, keep_alive )
    expiry_time = Time.now.to_i+keep_alive
    @expires[expiry_time] = [] unless @expires.has_key?(expiry_time)
    @expires[expiry_time].push( img_id )
  end
  
  # Removes all expired images.
  def expire_keepalives
    curr_time = Time.now.to_i
    @expires.keys.sort.each do |exp_time|
      if exp_time < curr_time
        @expires[exp_time].size.times do |incr|
          img_id = @expires[exp_time].shift
          if @imgs[:by_id].has_key?(img_id)
            ses_id = @imgs[:by_id][img_id][3]
            del_img( img_id, ses_id )
          end
        end
        @expires.delete(exp_time) if @expires[exp_time].size == 0
      end
    end
  end
  
end
end

Version data entries

105 entries across 105 versions & 2 rubygems

Version Path
rsence-pre-2.1.0.16 plugins/ticket/lib/img.rb
rsence-pre-2.1.0.15 plugins/ticket/lib/img.rb
rsence-pre-2.1.0.14 plugins/ticket/lib/img.rb
rsence-pre-2.1.0.13 plugins/ticket/lib/img.rb
rsence-pre-2.1.0.12 plugins/ticket/lib/img.rb
rsence-pre-2.1.0.11 plugins/ticket/lib/img.rb
rsence-pre-2.1.0.10 plugins/ticket/lib/img.rb
rsence-pre-2.1.0.9 plugins/ticket/lib/img.rb
rsence-pre-2.1.0.8.pre plugins/ticket/lib/img.rb
rsence-pre-2.1.0.7.pre plugins/ticket/lib/img.rb
rsence-pre-2.1.0.6.pre plugins/ticket/lib/img.rb
rsence-pre-2.1.0.4.pre plugins/ticket/lib/img.rb
rsence-pre-2.1.0.3.pre plugins/ticket/lib/img.rb
rsence-pre-2.1.0.2.pre plugins/ticket/lib/img.rb
rsence-pre-2.1.0.1.pre plugins/ticket/lib/img.rb
rsence-2.0.9.23 plugins/ticket/lib/img.rb
rsence-2.0.9.22.pre plugins/ticket/lib/img.rb
rsence-2.0.9.21.pre plugins/ticket/lib/img.rb
rsence-2.0.9.20.pre plugins/ticket/lib/img.rb
rsence-2.0.8.19 plugins/ticket/lib/img.rb