UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'mygO4qvVVnH1WPLo2rXamg+r3XuUKI6Cx3tVLEgJEBE=' 
WHERE 
  key_id = '4b5d8e820975a912890f55e46d2a0c402e8901f1b022ab44caa87a0dd1220729' 
  AND (
    token = 'mygO4qvVVnH1WPLo2rXamg+r3XuUKI6Cx3tVLEgJEBE=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00053