UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'pVUue9lB3k4SSiLVGF0eNc8xUlEUWYq8xzrh6L8jr+Q=' 
WHERE 
  key_id = '8037667f81e79d5d3268932d070782dd9826b8cf4316e944030ae1f3b801ff98' 
  AND (
    token = 'pVUue9lB3k4SSiLVGF0eNc8xUlEUWYq8xzrh6L8jr+Q=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00037