def increment_for(obj)
      # decide the time of event asap
      ts = Time.now.ceil.to_i

      if obj.class.ancestors.include?Cequel::Record
        args = obj.key_attributes.collect { |k,v|  v.to_s }
        cache_key = generate_key(ts, obj.class.name, *args)

        val = Cequel::Record.redis.get(cache_key)
        if val.nil?
          val = 1
        else
          val = val.to_i + 1
        end

        ttl = (time_window + 1) * 60

        # Update a sharded counter
        Cequel::Record.redis.setex(cache_key, ttl, val)

        # Optionally, update the index
        index_key = generate_index_key(ts, obj.class.name, *args)
        index_present = Cequel::Record.redis.get(index_key).try(:to_i)
        if index_present != 1
          Cequel::Record.redis.setex(index_key, ttl, 1)
        end
      end

    end
def increment_for(obj)
      # decide the time of event asap
      ts = Time.now.ceil.to_i

      if obj.class.ancestors.include?Cequel::Record
        args = obj.key_attributes.collect { |k,v|  v.to_s }
        cache_key = generate_key(ts, obj.class.name, *args)

        val = Cequel::Record.redis.get(cache_key)
        if val.nil?
          val = 1
        else
          val = val.to_i + 1
        end

        ttl = (time_window + 1) * 60

        # Update a sharded counter
        Cequel::Record.redis.setex(cache_key, ttl, val)

        # Optionally, update the index
        index_key = generate_index_key(ts, obj.class.name, *args)
        index_present = Cequel::Record.redis.get(index_key).try(:to_i)
        if index_present != 1
          Cequel::Record.redis.setex(index_key, ttl, 1)
        end
      end

    end
Increments the counter for a model.
 @param [Object] obj The model instance for whom counter would be
   incremented