UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'eu9M2u+ouglr705vlMmfmAYlbO85glhm+obZ8npgyNU=' 
WHERE 
  key_id = '6b1018ddce96ef2b0870932003e3a75ae310f3536d27e564c390d723af362334' 
  AND (
    token = 'eu9M2u+ouglr705vlMmfmAYlbO85glhm+obZ8npgyNU=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00023