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

Query time 0.00037