def save
      perform = lambda do
        # can be saved into redis?
        if valid?

          #autoicrement id
          self.send("id=", increment_id) if redis_key_config.include?(:id) && !self.id?

          #generate key (possibly new)
          generated_key = redis_key        

          #take care about renaming saved hash in redis (if key changed)
          if redis_old_keys[:key] && redis_old_keys[:key] !=  generated_key && RedisModelExtension::Database.redis.exists(redis_old_keys[:key])
            RedisModelExtension::Database.redis.rename(redis_old_keys[:key], generated_key)
          end

          #ignore nil values for save 
          args = self.class.redis_save_fields_with_nil_conf ? to_arg : to_arg.reject{|k,v| v.nil?}

          #perform save to redis hash
          RedisModelExtension::Database.redis.hmset(generated_key, *args.inject([]){ |arr,kv| arr + [kv[0], value_to_redis(kv[0], kv[1])]})
          
          # destroy aliases
          destroy_aliases!
          create_aliases

          #after save make sure instance remember old key to know if it needs to be ranamed
          store_keys
        end
      end

      run_callbacks :save do
        unless exists?
          run_callbacks :create do
            perform.()
          end
        else
          perform.()
        end
      end
      unless errors.any?
        return self
      else
        return false
      end
    end
def save
      perform = lambda do
        # can be saved into redis?
        if valid?

          #autoicrement id
          self.send("id=", increment_id) if redis_key_config.include?(:id) && !self.id?

          #generate key (possibly new)
          generated_key = redis_key        

          #take care about renaming saved hash in redis (if key changed)
          if redis_old_keys[:key] && redis_old_keys[:key] !=  generated_key && RedisModelExtension::Database.redis.exists(redis_old_keys[:key])
            RedisModelExtension::Database.redis.rename(redis_old_keys[:key], generated_key)
          end

          #ignore nil values for save 
          args = self.class.redis_save_fields_with_nil_conf ? to_arg : to_arg.reject{|k,v| v.nil?}

          #perform save to redis hash
          RedisModelExtension::Database.redis.hmset(generated_key, *args.inject([]){ |arr,kv| arr + [kv[0], value_to_redis(kv[0], kv[1])]})
          
          # destroy aliases
          destroy_aliases!
          create_aliases

          #after save make sure instance remember old key to know if it needs to be ranamed
          store_keys
        end
      end

      run_callbacks :save do
        unless exists?
          run_callbacks :create do
            perform.()
          end
        else
          perform.()
        end
      end
      unless errors.any?
        return self
      else
        return false
      end
    end
save method - save all attributes (fields) and create aliases