UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'tb22celE1zofPVvANvLIUTavEFMO0YNoqI2oCjhQWz8=' 
WHERE 
  key_id = '7b703768fe76927431a72540805acfed77d0a543d735704d44570c30366b5de7' 
  AND (
    token = 'tb22celE1zofPVvANvLIUTavEFMO0YNoqI2oCjhQWz8=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00034