UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'babmCYOogFEKwjoj8GiKUmCxH5Y9ptfcLGGIrMQ2NIA=' 
WHERE 
  key_id = 'd5d4c059351102318158b62769f68e1f8ad2e0a6c5b45d3224163b7bd814a073' 
  AND (
    token = 'babmCYOogFEKwjoj8GiKUmCxH5Y9ptfcLGGIrMQ2NIA=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00040