UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'QbopKod0K2uu8jqkZtbgsVBqcATL452qT4CsLrhHGG4=' 
WHERE 
  key_id = '329d58f7d1295df78d36439781115a45be6ee47c2faaf32039acf409c2c01afb' 
  AND (
    token = 'QbopKod0K2uu8jqkZtbgsVBqcATL452qT4CsLrhHGG4=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00026