UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Aly0l0jJcVtxcqp3r66MaXQwrbHQO1xtwBGk9LOf5As=' 
WHERE 
  key_id = '6dfbc10b9c976725bfababa5600d1484260280e35d41330926cf947c43bbd495' 
  AND (
    token = 'Aly0l0jJcVtxcqp3r66MaXQwrbHQO1xtwBGk9LOf5As=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00030