UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'r+ZK7bbtd/MuOq3naLZD4ueX6XAtdyykNmrJy/ntwdo=' 
WHERE 
  key_id = '541e40388dca2f3b978a17da1ab60325547e460a8151a070c4dc0496ac51b020' 
  AND (
    token = 'r+ZK7bbtd/MuOq3naLZD4ueX6XAtdyykNmrJy/ntwdo=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00043