UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'In7gygRlk/cQoyBPO7eYmj97NZfeDTezYwLvFLxVgSs=' 
WHERE 
  key_id = 'd2d97bccef810bef8c34b599a380cd45cc418d6884432da8719f2f1120aa730f' 
  AND (
    token = 'In7gygRlk/cQoyBPO7eYmj97NZfeDTezYwLvFLxVgSs=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00038