UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'X57plJm/h2u9H+uh8t1uttPc/isS2PiV0NdNQKqCbNA=' 
WHERE 
  key_id = '8911d929a21333123354b42e6b85c2050d5a8544f3258281cf62f6d297e35235' 
  AND (
    token = 'X57plJm/h2u9H+uh8t1uttPc/isS2PiV0NdNQKqCbNA=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032