UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'F19FfqZBZc1z9zkptSTRSY0KYHja9wKZ5AUGIVXlUS8=' 
WHERE 
  key_id = '15b8df559089203d93e1252b9192601b5376cb354f703e08143e366780d519d5' 
  AND (
    token = 'F19FfqZBZc1z9zkptSTRSY0KYHja9wKZ5AUGIVXlUS8=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00083